A complete demonstration of Agent-to-Agent (A2A) protocol communication with AAuth (Agent-to-Agent Authentication) signature-based authentication. This project showcases a full end-to-end implementation of AAuth using both HWK (Header Web Key) and JWKS (JSON Web Key Set) signature schemes per the AAuth specification.
This repository provides a complete, working example of:
- A2A Protocol 0.3.0: Agent-to-agent communication using the A2A protocol
- AAuth Signing: Cryptographic signing of all agent-to-agent requests using HTTP Message Signatures (RFC 9421)
- AAuth Verification: Signature verification on incoming requests
- Multiple Signature Schemes:
- HWK (Header Web Key): Pseudonymous authentication with public key in header
- JWKS (JSON Web Key Set): Identified agent authentication with key discovery
- JWT (Auth Token): User-delegated authorization with Keycloak-issued auth tokens
- User-Delegated AAuth: Consent flow (Backend โ Keycloak โ user consent โ auth token), resource tokens, and multi-hop token exchange (Supply Chain Agent โ Market Analysis Agent)
- Multi-Agent Architecture: Three agents communicating with signed requests
- Key Discovery: JWKS endpoints and metadata discovery per AAuth specification
- User Authentication: Keycloak OIDC integration for user-facing frontend
โโโโโโโโโโโโโโโโโโโ
โ User Browser โ
โ (React UI) โ
โโโโโโโโโโฌโโโโโโโโโ
โ Keycloak OIDC
โผ
โโโโโโโโโโโโโโโโโโโ AAuth Signed โโโโโโโโโโโโโโโโโโโโโโโโ
โ Backend API โ โโโโโโโโโโโโโโโโโโโโโบ โ Supply Chain Agent โ
โ (FastAPI) โ (JWKS/HWK Scheme) โ (A2A Agent) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโโโโโโโ
โ AAuth Signed
โ (JWKS/HWK Scheme)
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Market Analysis โ
โ Agent (A2A Agent) โ
โโโโโโโโโโโโโโโโโโโโโโโโ
-
Backend (
backend/): FastAPI service that:- Authenticates users via Keycloak OIDC
- Signs requests to supply-chain-agent using AAuth (HWK or JWKS)
- Exposes JWKS endpoints (
/.well-known/aauth-agent,/jwks.json)
-
Supply Chain Agent (
supply-chain-agent/): A2A agent that:- Verifies incoming AAuth signatures from backend
- Signs outgoing requests to market-analysis-agent using AAuth
- Exposes JWKS endpoints for key discovery
- Orchestrates supply chain optimization workflows
-
Market Analysis Agent (
market-analysis-agent/): A2A agent that:- Verifies incoming AAuth signatures from supply-chain-agent
- Provides market analysis and demand forecasting
- Acts as a leaf agent (receives requests, doesn't make downstream calls)
-
Frontend (
supply-chain-ui/): React application that:- Provides user interface for supply chain optimization
- Authenticates users via Keycloak
- Calls backend API with user credentials
-
Agent Gateway (
agentgateway/): Gateway configuration for routing agent traffic
- Python 3.12+
- Node.js 16+
- Keycloak 26.2.5+ (for user authentication)
uvpackage manager (recommended) orpip
Each agent has its own virtual environment. Setup with uv:
# Backend
cd backend
uv sync
cd ..
# Supply Chain Agent
cd supply-chain-agent
uv sync
cd ..
# Market Analysis Agent
cd market-analysis-agent
uv sync
cd ..cd supply-chain-ui
npm install
cp env.example .env
# Edit .env with your Keycloak configuration
cd ..- Start Keycloak:
docker run -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:26.2.5 start-dev - Access Admin Console: http://localhost:8080
- Create realm:
aauth-test - Create client:
supply-chain-ui(public client, standard flow enabled) - Create user:
mcp-userwith passworduser123
Each component needs environment configuration. Copy env.example to .env in each directory and set values. For user-delegated AAuth (consent + token exchange), see docs/AAUTH_CONFIGURATION.md.
# Backend
cd backend
cp env.example .env
# Edit .env - set BACKEND_AGENT_URL, AAUTH_SIGNATURE_SCHEME, KEYCLOAK_*, AAUTH_CALLBACK_URL, etc.
# Supply Chain Agent
cd ../supply-chain-agent
cp env.example .env
# Edit .env - set SUPPLY_CHAIN_AGENT_ID_URL, AAUTH_SIGNATURE_SCHEME, KEYCLOAK_AAUTH_ISSUER_URL, etc.
# Market Analysis Agent
cd ../market-analysis-agent
cp env.example .env
# Edit .env - set MARKET_ANALYSIS_AGENT_ID_URL, AAUTH_SIGNATURE_SCHEME, AAUTH_AUTHORIZATION_SCHEME, KEYCLOAK_*, etc.Terminal 1 - Backend:
cd backend
uv run .
# Runs on http://localhost:8000Terminal 2 - Supply Chain Agent:
cd supply-chain-agent
uv run .
# Runs on http://localhost:9999Terminal 3 - Market Analysis Agent:
cd market-analysis-agent
uv run .
# Runs on http://localhost:9998Terminal 4 - Frontend:
cd supply-chain-ui
npm start
# Runs on http://localhost:3000This project demonstrates complete AAuth implementation with:
Both HWK and JWKS schemes are supported and configurable via AAUTH_SIGNATURE_SCHEME:
-
HWK (Header Web Key): Pseudonymous authentication
- Public key embedded directly in
Signature-Keyheader - No identity verification, just proof-of-possession
- Example:
scheme=hwk kty="OKP" crv="Ed25519" x="..."
- Public key embedded directly in
-
JWKS (JSON Web Key Set): Identified agent authentication
- Agent identifier (
id) and key ID (kid) inSignature-Keyheader - Receivers fetch JWKS from agent's metadata endpoint
- Provides agent identity verification
- Example:
scheme=jwks id="http://agent.example" kid="key-1"
- Agent identifier (
-
JWT (Auth Token): User-delegated authorization
- Auth token from Keycloak (after user consent or token exchange) in
Signature-Keyheader - Receivers verify JWT with Keycloak JWKS and validate claims (
aud,agent,act, etc.) - Example:
scheme=jwt jwt="<auth-token>" - See docs/USER_DELEGATED_AAUTH.md for the full flow
- Auth token from Keycloak (after user consent or token exchange) in
Agents expose JWKS endpoints for key discovery:
/.well-known/aauth-agent: Agent metadata withagentidentifier andjwks_uri/jwks.json: JSON Web Key Set containing public signing keys
Signing (Outgoing Requests):
- Backend โ Supply Chain Agent:
backend/app/services/aauth_interceptor.py - Supply Chain Agent โ Market Analysis Agent:
supply-chain-agent/aauth_interceptor.py
Verification (Incoming Requests):
- Supply Chain Agent:
supply-chain-agent/agent_executor.py(lines 480-760) - Market Analysis Agent:
market-analysis-agent/agent_executor.py(lines 280-501)
JWKS Endpoints:
- Backend:
backend/app/main.py(lines 89-110) - Supply Chain Agent:
supply-chain-agent/__main__.py(lines 163-184)
HTTP Header Capture:
- Both agents use
http_headers_middleware.pyto capture headers for signature verification
This project serves as a complete reference implementation for AAuth. To learn how AAuth works:
- Start with signing: See how requests are signed in
aauth_interceptor.pyfiles - Understand verification: See how signatures are verified in
agent_executor.pyfiles - Explore JWKS discovery: See how keys are discovered via metadata endpoints
- Review the specification: See SPEC.md for the complete AAuth specification
Each component's README includes detailed AAuth documentation:
backend/README.md- Backend AAuth signingsupply-chain-agent/README.md- Both signing and verificationmarket-analysis-agent/README.md- Verification only
- โ HTTP Message Signatures (RFC 9421) for request signing
- โ HWK Scheme - Pseudonymous authentication
- โ JWKS Scheme - Identified agent authentication with key discovery
- โ JWT Scheme - User-delegated auth tokens (Keycloak-issued; JWKโPEM for verification)
- โ
User consent flow - Backend redirects to Keycloak consent; callback exchanges code for auth token and retries with
scheme=jwt - โ Resource tokens - Supply Chain Agent and Market Analysis Agent issue resource tokens on 401 (Agent-Auth header)
- โ
Token exchange - Supply Chain Agent exchanges upstream auth token for new token when calling Market Analysis Agent (SPEC ยง9.10;
actclaim) - โ Canonical Authority - Proper authority handling per SPEC 10.3.1
- โ Content-Digest - RFC 9530 compliant body digest
- โ Ephemeral Keys - Per-process keypair generation
- โ
Metadata Discovery -
/.well-known/aauth-agentendpoints - โ
JWKS Endpoints -
/jwks.jsonfor public key distribution
- โ A2A Protocol 0.3.0 compliance
- โ Agent Cards - Public and extended agent cards
- โ Skills - Agent capability definitions
- โ Delegation - Agent-to-agent delegation
- โ JSON-RPC Transport - Standard A2A transport
- โ OpenTelemetry Tracing - Distributed tracing with Jaeger
- โ Structured Logging - Comprehensive logging with DEBUG/LOG_LEVEL support
- โ Trace Context Propagation - End-to-end trace correlation
- AAuth Specification - Complete AAuth specification
- User-Delegated AAuth Flow - Consent flow, resource tokens, token exchange (Backend โ SCA โ MAA)
- AAuth Configuration - Environment variables and Keycloak setup for all components
- Backend README - Backend API and AAuth signing documentation
- Supply Chain Agent README - Agent documentation with AAuth details
- Market Analysis Agent README - Agent documentation with AAuth details
This project is designed as a learning resource for:
- AAuth Protocol: Complete implementation of agent-to-agent authentication
- A2A Protocol: Agent-to-agent communication patterns
- HTTP Message Signatures: RFC 9421 implementation
- JWKS Discovery: Key discovery patterns
- Multi-Agent Systems: Orchestration and delegation patterns
Set AAUTH_SIGNATURE_SCHEME in each component's .env:
hwk- Header Web Key (pseudonymous)jwks- JSON Web Key Set (identified agent)jwt- Auth token (user-delegated; used by backend/agents when an auth token is available after consent or token exchange)
For the full user consent and multi-hop flow:
- Backend: Set
AAUTH_AUTHORIZATION_SCHEME(or equivalent) so that when Supply Chain Agent returns 401 with Agent-Auth, the backend requests an auth token from Keycloak. ConfigureAAUTH_CALLBACK_URLandAAUTH_FRONTEND_REDIRECT_URLfor the consent callback and post-consent redirect. - Supply Chain Agent: Can act as a resource (issue resource tokens on 401) and perform token exchange when Market Analysis Agent returns 401. Set
KEYCLOAK_AAUTH_ISSUER_URLand optional token endpoint. - Market Analysis Agent: Set
AAUTH_AUTHORIZATION_SCHEME=user-delegatedto requirescheme=jwtand return 401 with resource token when missing. SetKEYCLOAK_AAUTH_ISSUER_URLfor JWT verification (Keycloak JWKS).
See docs/USER_DELEGATED_AAUTH.md for the full flow and docs/AAUTH_CONFIGURATION.md for all environment variables.
Configure agent identifiers for JWKS scheme:
BACKEND_AGENT_URL- Backend agent identifierSUPPLY_CHAIN_AGENT_ID_URL- Supply chain agent identifierMARKET_ANALYSIS_AGENT_ID_URL- Market analysis agent identifier
Canonical authority is automatically derived from agent ID URLs per SPEC 10.3.1.
This is a demonstration project. Contributions welcome!
- Fork the repository
- Create a feature branch
- Make your changes
- Ensure AAuth compliance per SPEC.md
- Submit a pull request
This project is for educational and demonstration purposes.
- AAuth Specification: By Dick Hardt
- A2A Protocol: Agent-to-Agent communication protocol
- HTTP Message Signatures: RFC 9421
- Keycloak: Identity and access management