Skip to content

Check the actor at ID-JAG redemption - #7255

Merged
jhrozek merged 3 commits into
mainfrom
as2-subject-mapping-2-actor-checks
Nov 23, 2026
Merged

jhrozek merged 3 commits into
mainfrom
as2-subject-mapping-2-actor-checks

Conversation

@jhrozek

@jhrozek jhrozek commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

For a resolve issuer nothing checked who the acting agent is. The act claim is copied into the issued token, it is the audit record of which agent acted for the user, and session binding uses it later. Resolution of the subject cannot be turned on until a missing, malformed or disallowed actor is refused, so this adds that check first.

  • For resolve issuers only, the handler reads the effective actor: the outermost act, with the ID-JAG's iss standing in when act has none.
  • A missing or malformed act, or an act.iss that is neither the ID-JAG's iss nor in actor_issuers, is refused with access_denied and the new actor_denied reason, before the actor policy runs.
  • The actor policy is built once per issuer at construction. A denial is actor_denied. A policy error means it could not decide, so it is server_error, not a denial.
  • The checks run after the client-audience check and before the code gate and before the jti is used up, so a refusal leaves the ID-JAG unused.
  • Refusals are logged with the issuer, client and reason, never the subject, the jti or an act value. A denial is logged at Debug. A policy that cannot decide is logged at Warn, because it is a server fault operators need to see.
  • A two-server integration test has AS-1 mint an ID-JAG through real issuance and AS-2 redeem it over HTTP. It asserts act.iss is the actor's issuer, not AS-1's.

Closes #7245

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (scoped: go test -race on pkg/authserver/server/tokenexchange/..., pkg/authserver/actor/... and pkg/authserver/, which includes the two-server integration test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Changes

File Change
pkg/authserver/server/tokenexchange/id_jag_actor.go New: per-issuer actor policies and checkActor
pkg/authserver/server/tokenexchange/id_jag_handler.go actorPolicies field, built in the constructor; checkActor call before the gate
pkg/authserver/server/tokenexchange/redemption_refusal.go actor_denied reason code
pkg/authserver/actor/policy.go Doc comment on DefaultPolicy.Evaluate only
docs/arch/17-token-exchange-delegation.md Refusal rows, actor-check bullet, gate and retry wording
*_test.go Unit tests for each check, plus the two-server integration test

Does this introduce a user-facing change?

Only for resolve issuers, which only embedders can configure and which are still refused on every redemption until resolution is turned on.

  • Before: every redemption from a resolve issuer that passed validation and the client and resource checks was refused with 400 access_denied, subject_unknown, whatever its act.
  • After: an ID-JAG with a missing or malformed act, a disallowed act.iss, or an actor the policy denies is refused with 400 access_denied, actor_denied. A policy that cannot decide gives 500 server_error. An ID-JAG whose actor passes is still refused by the gate with subject_unknown. None of these uses up the jti.
  • namespaced issuers: no change.

Special notes for reviewers

  • A policy error is server_error, not actor_denied. A broken policy is a server fault, and a client that reads actor_denied concludes its actor is not allowed.
  • The issuer pre-check repeats what DefaultPolicy does on purpose. Policy is an interface, and another implementation might not check the issuer.
  • The default policy checks only the actor's issuer. It does not restrict actors per subject or per client: any act.sub at an allowed issuer passes. Which clients may redeem is bounded separately by the client checks. The docs and the comment on DefaultPolicy.Evaluate say so.
  • The check relies on the earlier change skipping the subject-binding step for resolve issuers, which a resolve issuer has none of.
  • Known limitation: an actor_issuers entry that is empty or contains # passes RunConfig validation and is refused only when the handler is built. By then an upstream client may already be registered. Only Go embedders can set ActorIssuers. Validating it earlier is left out of this PR.

jhrozek and others added 2 commits November 23, 2026 22:17
For a resolve issuer nothing checked who the acting agent is, yet the
act claim is copied into the issued token, is the audit trail, and is
the basis for session binding. Resolution of the subject cannot be
turned on until a missing, malformed or disallowed actor is refused.

For resolve issuers only, the handler now reads the effective actor
(the outermost act, with the ID-JAG's iss standing in when act has
none). A missing or malformed act, or an act.iss that is neither the
ID-JAG's iss nor in actor_issuers, is refused with access_denied and
the new actor_denied reason, before the actor policy runs. The policy
is built once per issuer at construction. A denial is actor_denied. A
policy error means the policy could not decide, so it is
server_error, not a denial. The checks run before the code gate and
before the jti is used up. Refusals are logged at Debug with the
issuer, client and reason, never the subject, the jti or an act value.

The default policy checks only the actor's issuer, so it does not
restrict actors per subject or per client. The docs and the doc comment
on DefaultPolicy.Evaluate say so, and say what Evaluate trusts in its
request.

Refs #7245

Co-authored-by: Mecatl <[email protected]>
The actor check reads the act.iss that AS-1's real issuance puts in an
ID-JAG, which is the actor's issuer and not AS-1's own. Unit tests feed
the handler hand-made claims, so they cannot show that the two ends
agree over HTTP.

AS-1 mints an ID-JAG through real issuance with a mocked actor token
validator, and AS-2 redeems it under a resolve issuer. The test decodes
the ID-JAG to assert act.iss is the actor issuer, not AS-1. With that
issuer in actor_issuers the redemption reaches the gate and is refused
with subject_unknown; with it unlisted the actor check refuses first
with actor_denied. startAS2With and startTwoServerIDJAGConfigured let a
test change AS-2's config.

Refs #7245

Co-authored-by: Mecatl <[email protected]>
@jhrozek
jhrozek requested a review from ChrisJBurns as a code owner November 23, 2026 21:17
@github-actions github-actions Bot added the size/M Medium PR: 300-599 lines changed label Nov 23, 2026
rdimitrov
rdimitrov previously approved these changes Nov 23, 2026

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve: the actor check is made at the right place and nothing blocking turned up.

Design: IDJAGHandler.HandleTokenEndpointRequest is the single redemption point for ID-JAGs, and the PR reuses the existing actor package (Effective, DefaultPolicy) instead of reimplementing it. The check runs after the client-audience check and before the gate and the jti consume, so a refused ID-JAG stays reusable. A policy error returns a 500 rather than a denial, which is correct. The only behaviour change is for resolve issuers, which are Go-embedder-only and are refused at the gate today anyway. So upgrade impact is a different refusal reason (actor_denied), and no CRD, CLI or persisted-state change.

Non-blocking notes (no action needed to merge):

  1. id_jag_actor.go:65-67: the inline ActorIssuers allowlist check repeats what DefaultPolicy.Evaluate already does. actorPolicies is only built from DefaultPolicy, so in production this branch is unreachable, and TestIDJAGActor_IssuerAllowlist ends up testing the duplicate. Consider dropping it, or noting that it guards a future injectable policy.
  2. subject_mode.go:73: validateSubjectMode does not reject empty or #-containing actor_issuers entries, but actor.NewDefaultPolicy (now called from newIDJAGIssuanceHandler) does. Such a config passes validation and fails later when the handler is built. Rejecting those entries in validateSubjectMode would surface the error at config time.
  3. id_jag_actor.go:92-99: the actor_policy_error 500 path is logged only at Debug. Logging it at Warn would make it visible to operators.

🤖 Reviewed with Claude Code

@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.67442% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.81%. Comparing base (a77ba4c) to head (ad5a3e0).

Files with missing lines Patch % Lines
.../authserver/server/tokenexchange/id_jag_handler.go 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7255      +/-   ##
==========================================
- Coverage   81.85%   81.81%   -0.05%     
==========================================
  Files         913      914       +1     
  Lines       92576    92619      +43     
==========================================
- Hits        75780    75778       -2     
- Misses      16791    16836      +45     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

A policy that cannot decide is a server fault the caller did not cause,
so operators need to see it. It was logged at Debug with the denials.
A denial stays at Debug because a caller can trigger it at request rate.

The comment on the issuer pre-check now says why it repeats the policy:
the handler holds the Policy interface, so actor_issuers must still bind
a future policy that does not check issuers. The retry paragraph in the
architecture doc now says only the access_denied refusals that a new
ID-JAG with the same claims would not change are not worth retrying.

Refs #7245

Co-authored-by: Mecatl <[email protected]>
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Nov 23, 2026

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of ad5a3e0: still approve. The new commit logs a policy that cannot decide at Warn (denials stay at Debug), and the comment and architecture-doc wording now match the code.

Of the earlier non-blocking notes: 1 (duplicate issuer check) is addressed by the comment saying it guards a future non-default Policy, and 3 (500 path only at Debug) is addressed by the Warn level. Note 2 (validateSubjectMode not rejecting empty or #-containing actor_issuers) is still open; it stays non-blocking.

🤖 Reviewed with Claude Code

@jhrozek
jhrozek merged commit ae8b232 into main Nov 23, 2026
47 of 48 checks passed
@jhrozek
jhrozek deleted the as2-subject-mapping-2-actor-checks branch November 23, 2026 22:31
@github-actions github-actions Bot mentioned this pull request Nov 24, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delegated access: actor checks at ID-JAG redemption

2 participants