Dispatch auth
What it is
Dispatch auth is the SDK module that proves an inbound A2A dispatch really came from the Svantic mesh. Every capability invocation Svantic routes to an agent can carry asvantic_auth envelope inside the DataPart. That envelope is either an HS256 JWT issued by the mesh (scheme: 'svantic_jwt') or a shared-secret comparison (scheme: 'shared_secret'). verify_dispatch_auth parses the envelope, checks the signature / secret, enforces audience binding and clock skew, and hands you a typed DispatchAuthContext you can log or pass into authorization decisions.
Two key points:
- Hosted-mode agents should enable it. Without dispatch auth, anyone who learns the agent’s public URL can invoke capabilities.
- Connected-mode agents get it for free on the transport. The outbound WebSocket is already authenticated, so dispatch auth there is accepted but optional.
AgentConfig.dispatch_auth is set. You only import the low-level helpers when you’re extracting auth from raw payloads yourself — e.g. a custom transport, a test harness, or a middleware before the SDK touches the request.
When to use it directly
- You’re hosting an agent outside
Agent.start()/attach()(custom transport). - You want an authorization check inside a capability handler based on the verified subject.
- You’re writing a compatibility layer that consumes A2A dispatches and want the same safety guarantees.
Functional usage
AgentConfig.dispatch_auth.
verify_dispatch_auth(data, config)
data is the DataPart payload as received by the SDK (the object your capability handler sees, before argument extraction).
- Returns a
DispatchAuthContexton success. - Throws
DispatchAuthVerifyErroron any failure;err.codelets you branch on the specific reason.
svantic_jwt— HS256 JWT signed with the agent’ssigning_secret. The verifier checksiss='svantic-mesh',aud=agent:<instance_id>, andexp. Claims (tenant_id,agent_type,instance_id,dispatch_id,jti) are surfaced on the returned context.shared_secret— opaque token compared in constant time against a locally configured secret. Supports per-credentials-ref secrets viashared_secretsmap.
VerifierConfig
DispatchAuthContext
Returned by a successful verification. Only scheme and expires_at are guaranteed; JWT claims are populated for svantic_jwt only.
DispatchAuthVerifyError
Thrown for every failure. err.code is one of:
Constants
MESH_DISPATCH_JWT_ISSUER
svantic_jwt dispatch tokens.
