Expand description
Server-side authentication interceptors.
These implement ServerInterceptor and reject unauthenticated requests
before the handler runs. They read the request’s HTTP headers from the
CallContext — which the JSON-RPC, REST, gRPC, and WebSocket bindings all
populate — so a single interceptor guards every transport.
| Interceptor | Validates | Feature |
|---|---|---|
ApiKeyAuthInterceptor | A configurable header against allowed keys (constant-time) | always |
BearerTokenAuthInterceptor | Authorization: Bearer <token> against allowed tokens (constant-time) | always |
JwtAuthInterceptor (auth-jwt feature) | A signed JWT (HS256/RS256/ES256), with static or remote (JWKS) keys | auth-jwt |
§Error mapping
An interceptor rejects a request by returning an A2aError; these
return A2aError::unauthenticated, which each binding answers with its
own status (ADR 0014, audit N36): HTTP 401 with a WWW-Authenticate
challenge on both HTTP bindings (the JSON-RPC body stays -32600), gRPC
UNAUTHENTICATED. A custom interceptor refusing an authenticated caller
returns A2aError::permission_denied for 403 / PERMISSION_DENIED.
The WebSocket binding checks per message after the upgrade, so it has no
status to send and answers the body alone. None of these interceptors
reveals why a credential was rejected.
§Example
use a2a_protocol_server::auth::BearerTokenAuthInterceptor;
use a2a_protocol_server::RequestHandlerBuilder;
let handler = RequestHandlerBuilder::new(Exec)
.with_agent_card(card())
.with_interceptor(BearerTokenAuthInterceptor::new(["secret-token-1", "secret-token-2"]))
.build()
.unwrap();Modules§
- caller_
id - The caller identities the bundled authenticators record (audit register R12).
- jwt
auth-jwt - JWT bearer-token authentication (HS256 / RS256 / ES256).
- throttle
- Throttling a peer that keeps failing authentication (spec §13.4: agents SHOULD implement rate limiting to prevent brute-force attacks).
Structs§
- ApiKey
Auth Interceptor - Rejects requests whose API-key header is absent or not in the allowed set.
- Auth
Failure Throttle - Refuses a peer that has failed authentication too often; see the module docs.
- Auth
Failure Throttle Config - Configuration for an
AuthFailureThrottle. - Authenticated
Principal - A resolved authenticated principal, stashed for downstream interceptors.
- Bearer
Token Auth Interceptor - Rejects requests whose
Authorization: Bearer <token>is absent or whose token is not in the allowed set. - Credential
Set - The credentials an interceptor accepts. Cloning gives another handle to the same set.
- Forwarded
Client Cert - Where a trusted proxy forwards the client certificate it verified, and which peers are trusted to forward one.
- Jwks
- A set of asymmetric verification keys (an RFC 7517 JWK Set).
- JwtAuth
Interceptor - A
ServerInterceptorthat authenticates requests with a signed JWT. - JwtValidator
- The set of claim checks applied after a JWT’s signature verifies.
- Mutual
TlsAuth Interceptor - Names the caller from the certificate it presented in a mutual-TLS
handshake (
CallContext::peer_certificate), and refuses a call that arrived without one.
Constants§
- AWS_
ALB_ CERT_ HEADER - The header an AWS Application Load Balancer in mutual-TLS verify mode forwards the leaf certificate in.
- ENVOY_
XFCC_ HEADER - The header Envoy and Istio forward the client certificate in.
- MAX_
ACTORS - The most actors a chain may name; a longer one is refused.
- MIN_
HS256_ SECRET_ LEN - The shortest HS256 secret
JwtValidatoraccepts, in bytes.
Type Aliases§
- Shared
Principal - Convenience alias for a shared principal.