Agent Auth Protocol

repository·main·Indexed 41 days ago

https://github.com/better-auth/agent-auth-protocol

An open-source standard for AI agent authentication, capability-based authorization, and service discovery. It enables autonomous and delegated agents to maintain distinct identities and scoped permissions using Ed25519 keypairs and short-lived JWTs. The protocol defines agent lifecycles (pending, active, expired, revoked, rejected, claimed), clock-based lifetime management, and user consent flows via Device Authorization (RFC 8628) and CIBA.

Tokens
56.7K
Snippets
128
Records
224
Agent score
50%

What's inside Agent Auth Protocol

  1. What is Agent Auth Protocol

    main

    Agent Auth is an open protocol designed to provide AI agents with their own independent identity, cryptographic keys, and scoped capabilities. Unlike traditional OAuth or session-based models that force agents to inherit a human user's or an application's identity, Agent Auth treats each runtime agent as a first-class principal.

    Key features include:

    • Per-agent identity: Every agent receives a unique ID and its own cryptographic keypair.
    • Scoped capabilities: Permissions are granted specifically to the agent for required actions.
    • Independent lifecycle: Agents can be revoked or expired individually without affecting users or other agents.
    • Full audit trail: Every request is attributed to a specific agent ID.
    • Discovery: Agents can automatically locate services via well-known endpoints.
  2. Overview of the Agent Auth Protocol

    main
    The Agent Auth Protocol is an implementation-oriented specification designed for AI agent identity, registration, and capability access. It provides a standardized way for AI agents to authenticate and interact with platforms, with built-in support for existing infrastructure such as HTTP APIs, OpenAPI operations, and MCP (Model Context Protocol) tools. The protocol is maintained by the Better Auth team and includes official SDKs for implementation.
  3. What is the Agent Auth Protocol?

    main

    Agent Auth is an open, implementation-oriented protocol designed to provide AI agents with a distinct identity that is separate from users, OAuth clients, or API keys. It provides a standardized way for agents to:

    • Register: Establish a formal identity within a system.
    • Authenticate: Prove their identity to services.
    • Receive Capabilities: Obtain specific permissions or functional scopes.
    • Operate: Execute tasks across various services as a first-class principal.

    This protocol addresses the limitations of traditional authentication models (like API keys or user-based OAuth) which lack visibility, granular scoping, isolation, and autonomous identity for agents operating without a human in the loop.

  4. What is a client in the Agent Auth Protocol?

    main

    A client acts as the intermediary between an AI agent and an authorization server. It is responsible for managing host and agent keys, communicating with servers, and exposing a standardized set of tools that agents use to discover providers, register themselves, authenticate, and execute capabilities.

    Key characteristics:

    • Communication: The protocol standardizes the client-to-server communication. It does not define how the agent communicates with the client (e.g., via MCP, SDK, or CLI).
    • Deployment Models:
      • MCP server: The most common model where the client runs as an MCP server that AI tools (like Claude Code or Cursor) connect to.
      • Embedded SDK: The client runs in the same process as the agent.
      • CLI tool: A command-line interface for managing agents and scripting workflows.
      • Remote service: A hosted service that agents connect to over a network.
  5. What is a server in the Agent Auth protocol?

    main

    In the Agent Auth protocol, a server acts as the authorization authority for a service (e.g., a bank, GitHub, or any API). It is responsible for managing the lifecycle and permissions of agents that interact with that service.

    Core Responsibilities:

    • Discovery: Publishing a configuration endpoint for client auto-configuration.
    • Registration: Managing host and agent identities using Ed25519 key verification.
    • Authorization: Managing capability grants, approval flows, and enforcing constraints.
    • Verification: Validating signed JWTs on every incoming request.
    • Lifecycle: Enforcing agent expiry, reactivation, and revocation.
  6. What is an agent in Agent Auth?

    main

    An agent is a runtime AI actor with its own server-side identity, granted capabilities, and lifecycle. It is the entity that is authenticated.

    Crucially, an agent is not the host application (like Claude Code or ChatGPT); it is the specific runtime actor within that environment (e.g., a specific conversation or task).

    To ensure security and auditability, every agent possesses:

    • Continuity: The ability to be recognized as the same actor over multiple requests.
    • Distinctiveness: The ability to be individually scoped, audited, and revoked without affecting other actors.

    Agent Auth provides these properties by assigning each agent its own Ed25519 keypair, registration, and capability set.

  7. Identify the runtime participants in Agent Auth

    main

    The protocol involves three primary runtime participants:

    NameRole
    AgentThe AI that needs to act. Has an agent ID and calls client tools.
    ClientThe process that exposes protocol tools to AI systems (MCP server, CLI, SDK). Holds a host identity, manages keys, and signs requests.
    ServerThe service's authorization server. Manages registrations, capabilities, approvals, and verification.

    Additionally, a User (Resource Owner) may be involved in the Approval phase if a registration is marked as pending.

  8. How authentication works in Agent Auth

    main

    Authentication in the Agent Auth Protocol is built on Ed25519 keypairs and short-lived JWTs. The protocol distinguishes between two primary token types:

    1. Host JWTs: Used by hosts for management operations such as registration, status checks, reactivation, revocation, and key rotation.
    2. Agent JWTs: Used by agents to execute capabilities. These are extremely short-lived (ideally expiring within 60 seconds) and must be re-signed for every request as there are no refresh tokens.

    Both hosts and agents use EdDSA over Ed25519 keypairs in JWK format. The private key remains on the client, while the server only stores public keys or JWKS URLs.

    {
      "kty": "OKP",
      "crv": "Ed25519",
      "x": "base64url-encoded-public-key"
    }
  9. Handle user approval and capability escalation

    main

    User Approval Flow

    When connecting to a new server for the first time, the client manages the approval process:

    1. Receives a verification URI and user code from the server.
    2. Presents these to the user.
    3. Polls the server's status endpoint until approval is granted.
    4. Returns the active agent.

    Once a host is trusted, future requests for default capabilities are auto-approved.

    Capability Escalation

    If an agent requires additional capabilities at runtime that were not part of the initial connection, use requestCapability. This always triggers an explicit user approval flow, even for trusted hosts.

    const result = await client.requestCapability({
      provider: "bank",
      capabilities: ["transfer_funds"],
      reason: "User asked to transfer money"
    });
    // Triggers approval flow if needed, returns updated grants
  10. OAuth 2.0 mechanisms used in Agent Auth

    main

    Agent Auth is a standalone protocol that reuses several established OAuth 2.0 and IETF standards for specific workflows:

    • User Consent (Device Authorization): Uses RFC 8628. The server returns a verification_uri and user_code. Instead of a standard token endpoint, the client polls GET /agent/status to check for the result.
    • Backchannel Consent (CIBA): Uses OpenID CIBA for autonomous agents that require user authorization without a browser interface.
    • Proof of Possession (DPoP): Uses RFC 9449 for high-security deployments, involving a separate proof JWT and cnf binding on the access token.
    • Token Validation (Introspection): The /agent/introspect endpoint follows the RFC 7662 model for resource servers validating JWTs externally.
    • Key Management (JWK/JWKS): Uses RFC 7517. Public keys use standard JWK format, and hosts/agents may publish keys at JWKS URLs to support rotation.
  11. Configure public keys for hosts and agents

    main

    Public keys for hosts and agents can be provided to the server in two ways:

    • Inline (JWK): The public key is sent directly during registration. This is the simplest method.
    • JWKS URL: The public key is published at a URL that the server can fetch. This is recommended for key rotation and multi-service deployments where multiple services need to verify the same key.

    In this protocol, Ed25519 is the only defined algorithm for keypairs.