Skip to content

ID-JAG redemption: compare the requested resource with the assertion's resource claim, and decide the default when it is omitted #6892

Closed

Description

@jhrozek

State today. "Add oauthproto/idjag with the XAA client and server rules" (#7103) settled the default: when the request has no resource and the ID-JAG has a single-value resource claim, the claim is used (idJAGResource in pkg/authserver/server/tokenexchange/id_jag_handler.go). That closed "ID-JAG grant ignores the assertion's resource claim and requires a form resource" (#6983).

What is left is the comparison. When the request names a resource that the claim does not cover, or the claim is malformed, the redemption is accepted. Only logDraftDepartures notices, and it logs resource_not_covered or resource_malformed. So a client holding an ID-JAG issued for gateway A can redeem it for a token to gateway B, if B's authorization server also trusts the issuer and B's policy allows the subject.

Draft-ietf-oauth-identity-assertion-authz-grant-06 §4.4.1: "The access token MUST be restricted to resources in the resource claim". Accepting the mismatch breaks that MUST. It is the authorization server that departs from the draft here, not the issuer.

Rule

resource claim Form resource Result
well-formed, covers it present accept (unchanged)
well-formed, does not cover it present refuse, invalid_target (today: accepted)
malformed any refuse, invalid_grant (today: claim ignored, the form decides)
single value absent use the claim (unchanged, from "Add oauthproto/idjag with the XAA client and server rules" (#7103))
array with more than one value absent refuse (unchanged)
absent present the form decides under the existing policy (unchanged)
absent absent invalid_request (unchanged)

Why:

  • Malformed is invalid_grant: the fault is in the assertion, and draft §4.4.3 ties invalid_grant to "the ID-JAG failed a validation rule in Section 4.4", which a re-issued ID-JAG may fix. Ignoring a malformed claim drops the issuer's restriction entirely.
  • Absent stays lenient: draft §4.4.1 lets the authorization server choose default resources when the claim is absent. Okta's documented redemption request sends only grant_type, assertion and scope, so clients that follow Okta keep working.
  • Mismatch is invalid_target: the ID-JAG is valid, but the client asked for a resource it does not cover. That is RFC 8707's "the requested resource is invalid". It also matches the handler's other resource refusals.

resource_not_covered and resource_malformed leave the draft-departure log, because they are now refusals.

Behaviour change for existing callers

  • Before: a form resource outside the claim was accepted when the subject binding allowed it, and a malformed claim was ignored.
  • After: both are refused.

A client that follows the draft or Okta's docs omits resource and is unaffected. Mecatl is unaffected because its issuer always signs the claim, and ToolHive's ID-JAG client already refuses to request a resource the claim does not cover (pkg/oauthproto/idjag/exchange.go).

Acceptance

  • A form resource not covered by a well-formed claim: invalid_target, no token issued.
  • A malformed claim (not a string or array of strings, an empty string or empty array, a non-string element, duplicates): invalid_grant, no token issued.
  • The unchanged rows keep passing.
  • Unit rows in id_jag_handler_test.go for string and array claims; a mismatch row in two_server_id_jag_integration_test.go.
  • The in-process delegated-agent flow test, step 6: a mismatch row (refused) and a malformed-claim row (hand-signed).
  • Tested against a real Okta-issued ID-JAG before relying on the mismatch refusal for Okta. Okta's docs disagree on whether the claim holds the API URL or the issuer.
  • docs/arch/17-token-exchange-delegation.md describes the rule (it still describes the exactly-one-resource rule).

Later, not in this change

Part of "Delegated access: subject mapping at ID-JAG redemption" (#6887). The client's own audiences remain a separate check, from "Stable pre-provisioned broker client for token exchange and ID-JAG redemption" (#6893).

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue needs initial triage by a maintainer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions