Support multi-hop delegation chaining
Description
TokenExchangeDelegationProvider.validateMayAct() currently hard-requires a may_act claim in every subject token used in a delegation exchange. A token produced by a prior delegation exchange carries act but no may_act, so it can't be used as a subject token in a further exchange — chaining fails with "Invalid may_act claim in the subject_token". This blocks multi-hop delegation (e.g., user → agent client → MCP server client → downstream service).
Per RFC 8693 Section 4.4, may_act is a pre-authorization hint for the first hop only; subsequent hops are meant to be authorized by AS-side policy. Auth0 (up to 5 levels), ScrambleID, WorkOS, and PingIdentity all support policy-driven authorization for chained hops.
This is a distinct concern from #52159/#53034 (merged as RejectMayActClaimExecutor, PR #52898), which re-validates an already-minted may_act claim for staleness on the response side. It doesn't gate whether a chained exchange should be allowed in the first place, and isn't a fit to extend for this.
Value Proposition
Enables multi-agent / multi-service delegation chains, a common pattern in AI agent architectures, without every intermediary needing a fresh may_act grant. Aligns Keycloak with how other identity providers handle chained delegation.
Goals
- Allow a subject token that already carries
act(from a prior delegation hop, or from admin impersonation) to be used in a further delegation exchange, without requiringmay_act. - Require clients to explicitly opt in to multi-hop chaining (not allowed by default), with a configurable maximum chain depth.
- Authorize each chained hop via a new, admin-configurable client policy check, evaluated before the exchange proceeds.
- Enforce a real-time delegate-permission check for every chained hop, reusing the existing FGAP
canDelegatepermission (already client-aware) — mandatory, not something a policy can disable. - Correctly nest the
actclaim at each hop per RFC 8693 Section 4.1, preserving the full delegation/impersonation history.
Proposed Configuration
require-actor-claim(boolean, defaulttrue):true— the subject token must carrymay_actoract; if neither is present, the exchange is denied outright. Amay_actclaim is validated as today. Anactclaim withoutmay_act(a chained hop) skips that structural check — since its presence already implies an earlier authorized hop — but still goes through the delegate-permission check below.false— skip themay_act/actpresence requirement entirely, for every exchange including what would be the first hop. The delegate-permission check becomes the sole gate.
- Delegate-permission check (
canDelegate, FGAP) — always enforced for chained hops, and for every exchange whenrequire-actor-claim=false. Not configurable off, since making it optional would allow disabling authorization on later hops entirely. max-chain-depth(integer) — caps how many hops a single delegation chain may contain.
Non-Goals
- Changing first-hop behavior —
may_actremains required by default for a non-chained exchange. - Extending
RejectMayActClaimExecutor— wrong layer for this (response-side, fires too late). - A new client-to-client FGAP permission type — the existing per-user, client-aware
canDelegatecheck already covers this (same mechanismClientDelegationScopeTypeuses today). - Re-verifying user consent at every hop — no plumbing exists for this today, and it would defeat the purpose of chaining.
- Cross-trust-boundary subject tokens (e.g. via
subject_issuer, relevant to ID-JAG/XAA) — not currently reachable; flagged as a future risk only.
Source: keycloak/keycloak