Expand description
The caller identities the bundled authenticators record (audit register R12).
A caller is named by how it authenticated as well as by what it
presented: api-key:<label>, bearer:<label>,
jwt:<issuer>:<subject>, or mtls:<name> for a mutual-TLS client
certificate. A JWT sub is unique only within its issuer
(RFC 7519 §4.1.2), and a key’s label is the deployer’s to choose, so
without the scheme and the issuer two callers could share a name, and
with it a task partition, a rate-limit budget, an approver allowlist
entry or the four-eyes check.
These functions build the same strings the interceptors do. Use them to
write an approver allowlist
(ApprovalGate::with_approvers)
or a migration map for stored partitions. The issuer is percent-encoded
(% and : only), so no two pairs of issuer and subject give the same
identity; a token with no iss has the empty issuer.
use a2a_protocol_server::auth::caller_id;
assert_eq!(caller_id::bearer("team-b"), "bearer:team-b");
assert_eq!(caller_id::api_key("globex"), "api-key:globex");
assert_eq!(
caller_id::jwt(Some("https://idp.example"), "alice"),
"jwt:https%3A//idp.example:alice"
);
assert_eq!(caller_id::jwt(None, "alice"), "jwt::alice");Functions§
- api_key
- The identity of a caller whose API key carries
label. - bearer
- The identity of a caller whose bearer token carries
label. - certificate_
fingerprint grpc-tlsortls-rustls - A certificate’s name when nothing else names it:
sha256:and the SHA-256 digest of its DER encoding, in lowercase hex. - jwt
- The identity of a caller whose JWT names
subject, fromissuer(theissclaim, when the token has one). - mtls
- The identity of a caller whose mutual-TLS certificate is named
name(by default itscertificate_fingerprint, withtls-rustlsorgrpc-tls).