Skip to main content

Constitutional Token Governance for AI Agents — ACGS × Auth0 Token Vault

Project description

acgs-auth0

PyPI Python License: AGPL-3.0

Constitutional token governance for AI agents.

acgs-auth0 bridges Auth0 Token Vault with ACGS MACI governance so the constitution, not the agent, decides which OAuth scopes can be requested. It supports offline pre-flight checks, step-up approval for elevated scopes, and audit logging around every exchange.

Installation

acgs-auth0 supports Python 3.11+.

pip install acgs-auth0
pip install acgs-auth0[langchain]

Quick Start

Define a Scope Policy

# constitution.yaml
token_vault:
  constitutional_hash: "608508a9bd224290"
  connections:
    github:
      EXECUTIVE:
        permitted_scopes: ["read:user", "repo:read"]
        high_risk_scopes: []
      IMPLEMENTER:
        permitted_scopes: ["read:user", "repo:read", "repo:write"]
        high_risk_scopes: ["repo:write"]

Validate and Exchange Tokens

from acgs_auth0 import ConstitutionalTokenVault, MACIScopePolicy
from acgs_auth0.token_vault import TokenVaultRequest

policy = MACIScopePolicy.from_yaml("constitution.yaml")
vault = ConstitutionalTokenVault(policy=policy)

request = TokenVaultRequest(
    agent_id="planner",
    role="EXECUTIVE",
    connection="github",
    scopes=["repo:read"],
    refresh_token="rt_example",
    tool_name="list_issues",
)

validation = vault.validate(request)
assert validation.permitted is True

response = await vault.exchange(request)
print(response.access_token, response.scope)

Step-Up for High-Risk Scopes

request = TokenVaultRequest(
    agent_id="builder",
    role="IMPLEMENTER",
    connection="github",
    scopes=["repo:write"],
    refresh_token="rt_example",
)

validation = vault.validate(request)
print(validation.step_up_required)

Tool Decorator

from acgs_auth0 import get_token_vault_credentials, with_constitutional_token_vault

with_github = with_constitutional_token_vault(
    policy,
    connection="github",
    scopes=["read:user", "repo:read"],
)

@with_github
async def list_issues(repo: str) -> str:
    creds = get_token_vault_credentials()
    return f"using {creds['token_type']} for {repo}"

Configuration

Set these environment variables for live Token Vault exchanges:

Variable Purpose
AUTH0_DOMAIN Auth0 tenant domain
AUTH0_CLIENT_ID Auth0 client ID
AUTH0_CLIENT_SECRET Auth0 client secret

Key Features

  • YAML-driven MACI role-to-scope governance.
  • Offline validation through MACIScopePolicy and ConstitutionalTokenVault.validate().
  • Auth0 Token Vault exchange flow with optional step-up handling for elevated scopes.
  • Audit primitives including TokenAuditLog and TokenAccessAuditEntry.
  • Decorator-based integration for LangChain or plain Python callables.

License

AGPL-3.0-or-later. Commercial licensing is available; contact hello@acgs.ai.

Links

Constitutional Hash: 608508a9bd224290

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

acgs_auth0-0.1.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

acgs_auth0-0.1.0-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file acgs_auth0-0.1.0.tar.gz.

File metadata

  • Download URL: acgs_auth0-0.1.0.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for acgs_auth0-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1623ba8db2c84daec380b3d09aa12fea54b6db66a5b21c1972ee8d0a61670230
MD5 c377f3bbaf5b7e90f4366c486b7810b4
BLAKE2b-256 95de40cf7473e4651cbcfef4eef3427934b3535a2bc748af489d9968b51e8ce3

See more details on using hashes here.

File details

Details for the file acgs_auth0-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: acgs_auth0-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for acgs_auth0-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8228665f4c664499f6472934a797331980d198662d0c66e5ccbcb6a999876ef2
MD5 16727b837c2e2ef491f8dcb33080d72e
BLAKE2b-256 c9bca55e522b5479e45e17498514c8d5cd31f8856b9b68f064cd4bd3df3c57d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page