Skip to main content

Enroll and verify agent identity

Goal: do the following for an agent:

  • prove it holds the private key it claims
  • bind it to an accountable person
  • let a resource server check its identity offline
  • refuse any call that carries an identity without a grant

Before you start:

  • The agent is registered, with a reconciled manifest (Register and reconcile a manifest).
  • pip install 'authzai[client]'.
  • The control plane is configured with your identity provider and an enrollment bearer:
SettingWhat it is
AGENTIC_AUTH_PRINCIPAL_IDP_ISSUERYour IdP's issuer, e.g. https://login.example.com
AGENTIC_AUTH_PRINCIPAL_IDP_JWKS_URLIts JWKS endpoint
AGENTIC_AUTH_PRINCIPAL_IDP_AUDIENCEThe audience its ID tokens carry for this control plane
AGENTIC_AUTH_PRINCIPAL_BINDING_CLAIMThe claim naming the agent the person owns (default agent)
AGENTIC_AUTH_ENROLL_TOKENThe bearer enrollment requires

1. Give the agent a key​

from agentic_auth.sdk import AgentKey

key = AgentKey.generate()
key.save("balance-agent.pem") # keep it where the agent runs; it never leaves

2. Enroll it, bound to a person​

The agent's owner signs in to your IdP. The resulting ID token names the agent in the binding claim ("agent": "agent://balance-agent"). enroll then does three things in one call:

  1. presents the agent's identity document
  2. signs the control plane's challenge with the key (proof of possession)
  3. hands over that ID token as the principal binding
from agentic_auth.sdk import AgenticAuthClient

ops = AgenticAuthClient(CONTROL_PLANE, admin_token=ADMIN_TOKEN)
agent_id = await ops.admin.agent_id("balance-agent")
outcome = await ops.enroll(
agent_id,
key=key,
agent_name="balance-agent",
principal_assertion=id_token, # from your IdP, naming agent://balance-agent
enroll_token=ENROLL_TOKEN,
)
outcome["status"] # "enrolled"

No binding, no admission. An ID token that names a different agent, has expired, or can't be verified against your IdP's keys gets "quarantined". The agent is identified, but authorized for nothing. A successful enrollment pins a trust anchor: the key, the manifest version and the principal.

3. Let the agent present its identity on every call​

Give the agent its own client, holding its key. Every grant it is issued then carries a signed Agent-Identity header next to Authorization:

agent = AgenticAuthClient(CONTROL_PLANE, identity_key=key, agent_name="balance-agent")
grant = await agent.authorize(ctx, target="mcp://accounts.internal/read_balance",
data_class="account.read")
grant.headers() # {"Authorization": ..., "Agent-Identity": ...}

4. Verify at the resource, offline​

The tool or API being called needs only the base install, pip install authzai, which is pyjwt[crypto] and nothing else. It bootstraps the issuer's keys and the agents' trust anchors once, then verifies every call with no network call:

from agentic_auth.verify import HttpAnchors, HttpJwks, InMemoryReplay, Verifier

verifier = Verifier(
issuer_jwks=HttpJwks(f"{CONTROL_PLANE}/.well-known/jwks.json"),
anchors=HttpAnchors(base_url=CONTROL_PLANE, token=AUDIT_READ_TOKEN, agents=["balance-agent"]),
replay=InMemoryReplay(),
)
await verifier.bootstrap()

admission = verifier.admit(request.headers, target="mcp://accounts.internal/read_balance")
if not admission.ok:
return 403, admission.reason

The verifier admits a call only with both a valid grant and a valid identity. If the call presents only an identity, it is refused with GRANT_MISSING. The resource server holds the read-only audit bearer, never the admin token. For a privileged tool, pass params= and privileged=True, and the transaction token must match those exact parameters.

To refuse agents that have not enrolled at the control plane itself as well, set AGENTIC_AUTH_IDENTITY_REQUIRED=true. Their calls are then denied with AGENT_NOT_ENROLLED.

5. Revoke when needed​

await ops.revoke(agent_id, reason="key compromised")

Revocation invalidates the trust anchor and every delegation chain built on it. The next hop by or through that agent is denied with AGENT_REVOKED. Verifiers pick revocations up from /v1/identity/revocations within their freshness window, 30 seconds by default.