Skip to content

Commit 3902417

Browse files
committed
substrate: inject an actor JWT minted through Control.MintActorJwt
Substrate's egress policy carries a second credential source beside `credential_uri`: `CredentialHeader.actor_jwt` (field 4, `ActorJWTSource` with `audiences` and `expiration_seconds`), agent-substrate/substrate#1960. Substrate's own Envoy egress mints that JWT for the actor behind the tunnel (agentgateway#2135, agentgateway#2141). The agentgateway egress read every entry as an `ate-secret://` URI, so an `actor_jwt` entry was denied with `403 invalid credential URI: `. `apply_effects` now injects, for an `actor_jwt` entry whose header the request carries, `<prefix><token>`, the token minted through `Control.MintActorJwt` on the policy's own control API backend with the entry's audiences and lifetime. It needs no credential provider. Tokens are cached per actor, sorted audiences and lifetime, and reused until a third of their lifetime remains; concurrent misses share one mint. A request without the header is forwarded unchanged and mints nothing. A failed mint denies the request: 403 when the actor is gone (`NotFound`), 503 when the control API is unavailable or times out, 500 otherwise (new `ProxyError::SubstrateEgressInternal`), the classes of Substrate's `mapActorJWTError`. A minted token that is empty or not a valid header value is a 500. The vendored `ateapi.proto` gains `ActorJWTSource`, `MintActorJwt` and its messages, wire-compatible with Substrate's (audiences = 1, expiration_seconds = 8, actor = 5, as after agentgateway#2421). Signed-off-by: Timo Derstappen <[email protected]>
1 parent e523afb commit 3902417

7 files changed

Lines changed: 589 additions & 8 deletions

File tree

‎crates/agentgateway/src/http/substrate/README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ Exact names rank ahead of single-label wildcards, then `*`; explicit ports rank
4747
ahead of all ports. Omitted HTTP/HTTPS ports default to 80/443. Passthrough requires
4848
ports. `replace_headers` resolves credentials only for headers already present
4949
in the actor's request, replacing any placeholder value.
50+
An entry with `actor_jwt` carries a JWT the gateway mints for the actor through
51+
`Control.MintActorJwt` on the `substrateEgress` backend, bound to the entry's
52+
audiences and lifetime; it needs no credential provider. A token is reused per
53+
actor, audiences and lifetime until a third of its lifetime remains. A failed
54+
mint denies the request: 403 when the actor is gone, 503 when the control API
55+
is unavailable or times out, 500 otherwise.

0 commit comments

Comments
 (0)