Enable rollout
auth.md is disabled by default. Enable it only after the agent auth migration has run:/auth.md. OAuth discovery also advertises agent_auth metadata at /.well-known/oauth-protected-resource and /.well-known/oauth-authorization-server.
service_auth flow
- The agent calls
POST /agent/identitywithtype: "service_auth", alogin_hint, and optional scopes. - The API creates a pending registration and returns a
claim_token,user_code, and verification URL. - The signed-in user opens
/agent/claim?user_code=.... The email on their Better Auth session must match thelogin_hint. - After claim completion, the agent exchanges the claim token at
/oauth2/tokenwith grant typeurn:agent-artifacts:params:oauth:grant-type:claim_token.
Anonymous flow
Anonymous registration is intentionally low privilege:- The agent calls
POST /agent/identitywithtype: "anonymous". - The API returns an unclaimed identity assertion and a claim token.
- The agent may exchange the assertion with grant type
urn:ietf:params:oauth:grant-type:jwt-bearerfor a short-lived pre-claim token. - To bind the agent to a user, the agent calls
POST /agent/identity/claimwith the claim token andlogin_hint. - The user confirms the code at
/agent/claim. - Claim completion revokes all pre-claim tokens. The agent must exchange the completed claim token for a fresh post-claim token.
Revocation
CallPOST /oauth2/revoke with a token parameter to revoke an auth.md access token. Revocation is idempotent.
Security properties
- Claim tokens, user codes, assertion IDs, and access tokens are stored only as SHA-256 hashes.
- Anonymous pre-claim tokens are marked unclaimed, short-lived, and limited to configured pre-claim scopes.
- Agent bearer tokens bypass CSRF checks only after token validation succeeds.
- MCP
tools/callaccepts valid agent/API-key bearer principals before falling back to Better Auth MCP OAuth. - Human login is not migrated; all claim completion still requires a Better Auth user session.