A2A agent cards and allowed callers
In the Agent2Agent (A2A) protocol, an agent describes itself with an agent card: its endpoint, skills, input and output formats, and how callers get tokens. Casdoor builds the card from the agent record, signs it, and serves it, so the card and the tokens come from the same place. Casdoor also decides which other agents may get a token to call the agent, and shows which tokens were issued.
Describe the agent
On the edit page of an agent, fill in Agent card (A2A):
| 字段 | 描述 |
|---|---|
| Publish agent card | Lets anyone read the card. Off, only the admins of the organization can |
| Version | Version of the agent, 1.0.0 when empty |
| Protocol binding | JSONRPC (default), HTTP+JSON or GRPC |
| Skills | What the agent can do: an ID, a name, a description, tags and example prompts for each |
| Input modes, Output modes | Media types the agent takes and returns, text/plain when empty |
| Streaming, Push notifications | Capabilities of the agent |
| Allowed callers | Agents that may get tokens to call this agent, see below |
The card needs the Listening URL of the agent, which goes into supportedInterfaces. Display name, description and the logo of the agent's application become the card's name, description and icon, and the organization becomes the provider.
Read the card
GET /api/get-agent-card?id=<organization>/<agent>
returns the card as plain JSON, without the usual status and data wrapper, so A2A clients can read it directly. Point an /.well-known/agent-card.json on the agent's own domain to this URL, or fetch it from Casdoor.
GET /api/get-agent-cards?owner=<organization>
returns the published cards of the active agents in an organization, a registry that other agents can search for skills. A disabled, expired or orphaned agent leaves the registry, and its card returns 404.
The card lists two ways to get a token, both from Casdoor:
openIdConnectSecurityScheme: a user's token, from Casdoor's OpenID configurationoauth2SecuritySchemewithclientCredentials: the calling agent's own token, withresourceset to the listening URL of the agent
Signature
Casdoor signs the card with the certificate of the agent's application, as A2A specifies: a JWS over the card in the JSON Canonicalization Scheme of RFC 8785, without the signatures field. The signature is in signatures:
"signatures": [
{"protected": "eyJhbGciOiJSUzI1NiIs...", "signature": "Qm9i..."}
]
The protected header carries alg, typ JOSE, the kid of the certificate, and jku, the JWKS of the application at /.well-known/<application>/jwks. To verify a card, remove signatures, canonicalize the rest, and check the JWS with that key. Casdoor builds the card each time it serves it, so the signature always matches the current record.
Allowed callers
When Allowed callers is empty, any client that may get tokens can get one for the agent. Add agents to it, and Casdoor issues a token for this agent only to them:
- a client credentials request whose
resourceis the agent's listening URL - a token exchange whose
audienceis the client ID of the agent's application, or whoseresourceis the listening URL
The caller is the agent whose application asks for the token, or, in a token exchange with an actor token, the agent that acts. An agent can always get a token for itself. Others get invalid_target:
{"error": "invalid_target", "error_description": "the agent: built-in/rogue may not call the agent: built-in/travel, it isn't in the allowed callers"}
A disabled, expired or orphaned agent gets no new tokens from anyone.
Calls
Calls on the edit page lists the latest 100 tokens issued to call the agent: when, which agent or application asked, for which user, the chain of agents acting in it, the scope, and whether the token is still valid. GET /api/get-agent-calls?id=<organization>/<agent> returns the same list for the admins of the organization.
示例
A travel agent at https://travel.example.com/a2a should only be called by the planner agent:
- Turn on Publish agent card for
travel, add a skillbook-flight, and addplannerto Allowed callers. - The planner reads
https://<casdoor>/api/get-agent-card?id=my-org/travel, finds the skill, and asks Casdoor for a token withgrant_type=client_credentialsandresource=https://travel.example.com/a2a. - The travel agent validates the token as any Casdoor token and checks that
audor the resource is itself. Another agent that asks for the same token getsinvalid_target. - The call shows in Calls of
travel.
To have the planner act for a user, exchange the user's token with audience set to the travel agent's client ID. See token exchange and tokens for one task.