Authentication
Security mechanisms for A2A protocol integration
Authentication in A2A
A2A is designed for enterprise environments where security is paramount. This document outlines the authentication approaches supported by the protocol.
Authentication Principles
A2A follows these key authentication principles:
- Standard-Based: Leverages established authentication standards
- Out-of-Band: Authentication happens outside the A2A protocol payloads
- Declarative: Agents declare their authentication requirements
- Enterprise-Compatible: Works with existing identity systems
Authentication Flow
The general authentication flow in A2A:
- Client discovers an agent through its Agent Card
- Agent Card declares required authentication schemes
- Client obtains appropriate credentials outside of A2A
- Client includes credentials in HTTP headers for A2A requests
- Agent validates credentials for each request
Supported Authentication Schemes
A2A aligns with OpenAPI Authentication and supports:
HTTP Authentication
- Basic Authentication: Username/password in Authorization header
- Bearer Authentication: Token-based authentication (JWT, OAuth tokens)
- API Keys: In header, query parameter, or cookie
OAuth 2.0
- Authorization Code Flow: For user-authorized access
- Client Credentials Flow: For server-to-server
- Implicit Flow: For browser-based applications (less secure)
OpenID Connect
- Identity Tokens: For user authentication
- UserInfo Endpoint: For additional user data
Custom Schemes
- mTLS: Mutual TLS for certificate-based authentication
- HMAC Signatures: Request signing for integrity verification
- Custom Headers: Proprietary authentication schemes
Agent Card Authentication Section
The Agent Card includes authentication requirements:
Mid-Task Authentication
Sometimes a task may require additional authentication during execution:
- Agent changes task status to "InputRequired"
- Agent includes authentication request in message
- Client obtains new credentials (possibly involving user)
- Client sends new credentials in message
- Agent validates and continues task execution
Security Best Practices
When implementing A2A authentication:
- Use TLS: Always secure communication with HTTPS
- Token Expiration: Use short-lived tokens when possible
- Least Privilege: Request only necessary permissions
- Credential Rotation: Implement regular key/secret rotation
- Audit Logging: Record authentication events
- Throttling: Implement rate limiting for failed auth attempts
Example: OAuth 2.0 Flow
- Agent Card specifies OAuth2 authentication with authorization server URL
- Client redirects user to authorization server
- User authenticates and grants permissions
- Authorization server returns authorization code
- Client exchanges code for access token
- Client includes token in Authorization header for A2A requests
- Agent validates token with authorization server
Implementation Considerations
- Multi-tenancy: Consider how to handle different users/organizations
- Delegated Authentication: Allow users to authorize on behalf of others
- Token Refresh: Implement token refresh flows for long-running tasks
- Cross-Domain: Account for CORS when integrating with browser clients