Repository navigation
Description
Part of "Delegated access: subject mapping at ID-JAG redemption" (#6887).
Branch: as2-subject-mapping-1-config (well under 200 lines). Phase: 1.
Problem. AS-2 cannot be told that an issuer's ID-JAGs name a user in AS-2's own user table. Every ID-JAG redemption issues <iss>#<sub>, which is not a local user, so the gateway cannot find that user's connections.
Change. On JWTBearerGrantPolicy, Go-only (json:"-"), set by embedders:
subject_mode:namespaced(default, today's behaviour) orresolve. The zero value never selectsresolve.resolveimplies the marker.actor_issuers:act.issvalues accepted besides the ID-JAG's owniss. Mecatl's agent identities come from their own issuer, not AS-1's.- Mecatl sets AS-2's trust through the
inbound_grantsissuer policies, andapplyJWTBearerPoliciescopies only a fixed set of fields into a newJWTBearerGrantPolicy. So both settings are also added, Go-only, toJWTBearerIssuerPolicyRunConfigand copied there; a test shows they survive that copy. - Refusals at startup, each with a test:
resolvetogether withsubject_bindings.resolveoractor_issuerson a namespaced issuer.resolveon an issuer that accepts plainjwt_bearer. An emptyaccepted_assertion_typesmeans both types, so aresolveissuer must setaccepted_assertion_types: [id_jag]; that also triggers the existing accepted-audiences check.resolvewhen AS-2 has no identity-provider upstream (the first upstream, OIDC), because resolution could never succeed.- AS-2's own issuer as a trusted issuer is already refused for every issuer today; no change.
- The code gate: an unexported constant
delegatedAccessEnabled = false. While false, every redemption from aresolveissuer is refused withaccess_deniedandsubject_unknown, before anything is consumed, and the server logs once at startup that resolution is not enabled in this build. It is not a setting, an acknowledgement or a build tag.
Acceptance. Each refusal has a test with its text. The gate test is built in-package with a resolve policy that would otherwise redeem, so removing the gate changes the result (a resolve issuer without subject_bindings is refused as subject_unknown anyway, so a test through plain config proves nothing). A namespaced issuer is unchanged. docs/arch/17-token-exchange-delegation.md documents the settings and the gate.
Before and after for embedders. Before: no such settings; every redemption issues <iss>#<sub>. After: unchanged for issuers that leave them out; a resolve issuer is refused on every redemption until "Delegated access: turn on subject resolution at ID-JAG redemption" lands.
Depends on. Nothing in code. It lands after tokenexchange-refactor-3-redeemer to avoid rebase churn in the ID-JAG constructor.
Unblocks. With "Delegated access: actor checks at ID-JAG redemption" and "Delegated access: resolve the ID-JAG subject and issue the marked token behind the gate", lets "Configure the embedded gateway's authorization server as AS-2" (stacklok/mecatl) start. That issue is complete only when "Delegated access: turn on subject resolution at ID-JAG redemption" lands.
Activity
Gate ID-JAG subject resolution behind a setting (stacklok#7254)