Repository navigation
Gate ID-JAG subject resolution behind a setting - #7254
Conversation
AS-2 cannot be told that an issuer's ID-JAGs name a user in its own user table: every redemption issues <iss>#<sub>, which is not a local user, so the gateway cannot find that user's connections. This adds the per-issuer setting that selects resolving the subject to a local user, closed by a code gate until resolution itself lands. Two Go-only (json:"-") settings on JWTBearerGrantPolicy, mirrored on JWTBearerIssuerPolicyRunConfig and copied by applyJWTBearerPolicies so embedders using inbound_grants reach them: subject_mode (namespaced, the default, or resolve) and actor_issuers (act.iss values accepted besides the ID-JAG's own iss). Config files and the CRD cannot set them. Startup refuses an unknown subject_mode, actor_issuers without resolve, resolve with subject_bindings, resolve on an issuer that accepts plain jwt_bearer assertions, and resolve without an OIDC first upstream. subject_bindings stays required for namespaced issuers only. A resolve issuer skips the subject-binding check at redemption. The unexported constant delegatedAccessEnabled (false) refuses every redemption from a resolve issuer with access_denied / subject_unknown after the client-audience check and before the jti is consumed, and the server logs one WARN at startup naming the affected issuers. Namespaced issuers are unchanged. Refs #7244 Co-authored-by: Mecatl <[email protected]>
rdimitrov
left a comment
There was a problem hiding this comment.
Approve: the config surface and the closed gate are in the right places, and nothing changes for existing deployments.
Design: Per-issuer policy lives in JWTBearerGrantPolicy and its validation, and redemption lives in IDJAGHandler, so putting SubjectMode and ActorIssuers there is the right owner. The gate refuses resolve before the jti is consumed. It also checks policy.SubjectMode directly, so it holds even if an embedder skips config validation, and the plain jwt_bearer handler can't reach a resolve issuer because validation forces the accepted type to id_jag. The new fields are Go-only (json:"-") and default to namespaced, so no CRD, RunConfig or API shape changes on upgrade. The first-upstream check runs from both RunConfig.Validate and Config.Validate, before upstream registration.
Non-blocking: for resolve issuers, checkIDJAGPolicy skips the whole binding check, including the per-resource one, and the subject is still built as <iss>#<sub>. The delegatedAccessEnabled constant is the only thing preventing issuance in that state. The follow-up that flips it must add resolution and the resource check in the same change. A comment at the early return saying so would help. The title says "behind a setting", but the gate is a constant.
🤖 Reviewed with Claude Code
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7254 +/- ##
==========================================
+ Coverage 81.66% 81.79% +0.13%
==========================================
Files 904 913 +9
Lines 91840 92576 +736
==========================================
+ Hits 74999 75727 +728
- Misses 16836 16844 +8
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The OIDC-first-upstream check added to RunConfig.Validate took its cyclomatic complexity to 16, over the linter's limit of 15. Move the check into a small method. Also say at the binding-check skip for resolve issuers that the change which opens the gate must add resolution and a per-resource check, as the review asked. Co-authored-by: Mecatl <[email protected]>
rdimitrov
left a comment
There was a problem hiding this comment.
Re-review of 359135c: still approve.
The new commit only moves the resolve-issuer upstream check out of RunConfig.Validate into a validateResolveIssuers helper to lower its complexity, and adds the comment at the SubjectModeResolve early return in checkIDJAGPolicy. The call keeps its position (after validateTrustedIssuers, before validateSPIFFEClientIDsNotDelegates), takes the same arguments and returns the error unwrapped, so behaviour is unchanged. The comment accurately records that resolve skips the binding check and that delegatedAccessEnabled = false is the only thing blocking issuance, so whoever opens the gate must add resolution and the per-resource check in the same change.
The one failing CI check is Test Go Code on TestDCRRecheckTick_KeepsCurrentClientOnFailure (pkg/authserver/runner/dcr_recheck_test.go), which this PR doesn't touch; it looks like a timing flake. #7172 addresses that test.
🤖 Reviewed with Claude Code
Summary
subis<iss>#<sub>. When an issuer's ID-JAGs name a user in AS-2's own user table, that value is not a local user, so the gateway behind AS-2 can't find the user's connections. This PR adds the per-issuer setting that will select "resolve the subject to a local user". It does not add the resolution itself. That comes in later changes, and until then a code gate keepsresolveissuers closed.json:"-" yaml:"-") settings toJWTBearerGrantPolicy, mirrored onJWTBearerIssuerPolicyRunConfigand copied byapplyJWTBearerPolicies, so embedders usinginbound_grantsreach them:subject_mode:namespaced(the default) orresolve.actor_issuers: theact.issvalues to accept besides the ID-JAG's owniss. Nothing reads it at redemption yet; the actor checks use it next.subject_mode,actor_issuerswithoutresolve,resolvewithsubject_bindings,resolveon an issuer that accepts plainjwt_bearerassertions, andresolvewithout an OIDC first upstream.subject_bindingsstays required fornamespacedissuers. Aresolveissuer skips the subject-binding check at redemption.delegatedAccessEnabled(false) refuses every redemption from aresolveissuer withaccess_denied/subject_unknown. The refusal comes after the client-audience check and before thejtiis consumed. The server logs one WARN at startup naming the affected issuers.Closes #7244
Type of change
Test plan
task test): ran the samego test -racecommand the task uses, onpkg/authserverandpkg/authserver/server/tokenexchange, not the whole repotask test-e2e)task lint-fix)Changes
pkg/authserver/server/tokenexchange/subject_mode.goSubjectMode, the gate, the startup WARN and the per-issuer validationpkg/authserver/server/tokenexchange/multi_issuer_validator.goresolve)pkg/authserver/server/tokenexchange/id_jag_handler.goresolve, WARN at constructionpkg/authserver/server/tokenexchange/jwt_bearer_handler.gorefuseSubjectUnknown()for the binding refusalpkg/authserver/inbound_grants.goapplyJWTBearerPoliciespkg/authserver/config.goresolvewithout an OIDC first upstream, inRunConfig.ValidateandConfig.Validatedocs/arch/17-token-exchange-delegation.md*_test.go(4 files)Does this introduce a user-facing change?
No for existing deployments.
namespacedis the default and behaves exactly as before. Config files and the CRD can't set the new fields, so only Go embedders can. For an embedder that setssubject_mode: resolve:400 access_deniedwithsubject_unknown. The ID-JAG is not consumed.Special notes for reviewers
resolveissuers is safe only while the gate is closed. Nothing is issued from aresolveissuer in this build. The change that flips the gate must add resolution in the same change.RunConfig.Validateruns before the runner registers with any upstream. A config that failed only later would leave an unused client registered at the provider on each restart with the default in-memory store.Config.Validatekeeps the check for callers that build aConfigdirectly.resolveissuer must listaccepted_assertion_typesas[id_jag]explicitly. Leaving it unset means both types, and only the ID-JAG handler has the gate.actor_issuersis validated but not yet enforced. The docs say so.