Skip to content

Authorization server: reason codes in error_description for ID-JAG redemption refusals #7030

Closed

Description

@ChrisJBurns

Part of #6887.

Problem

When the authorization server refuses an ID-JAG redemption (the RFC 7523 JWT-bearer grant), the invalid_grant response says nothing a client can act on: the error_description is free text, if present. A client can't tell these cases apart:

  • an assertion that will never be accepted (bad signature, wrong audience, expired, replayed);
  • a missing approval that the user can grant;
  • any other refusal.

Mecatl's broker redeems ID-JAGs at the gateway's authorization server (AS-2). Its design asks AS-2 to start error_description with a reason code, alone or followed by a colon and text. The reason code lets the broker map each refusal to an outcome (credentials-and-lifecycle.md, step 8; Error reasons):

Case Response
Assertion checks fail: signature, issuer, audience, time claims, a replayed jti 400 invalid_grant, error_description=invalid_assertion
Subject not mapped, or approval missing, in embedded (implicit-approval) mode 400 access_denied, error_description=subject_unknown
Approval pending, under an approval-continuation profile advertised in metadata 400 access_denied, error_description=consent_required, with an error_uri (decided in "Delegated access: user approval at an external gateway" (#7158))
Requested resource not allowed by policy 400 access_denied, error_description=resource_denied. invalid_target stays only for a resource parameter that is malformed or not covered by the ID-JAG's resource claim
Storage unavailable 503 or server_error

The reason grammar follows RFC 6749 §5.2's error_description character set: lowercase letters and underscores, optionally followed by : text. The approval-continuation profile (consent_required with error_uri) belongs to "Delegated access: user approval at an external gateway" (#7158), which decides its error code. Draft -06 §4.4.3 points to access_denied. This issue covers the grammar and the invalid_assertion, subject_unknown, actor_denied and resource_denied reasons.

What the error code means. Following draft -06 §4.4.3, invalid_grant means the ID-JAG failed a validation rule and a re-issued one may succeed; access_denied means the ID-JAG is valid but the user, client or actor is not authorized here, and a re-issued one will not help. invalid_assertion is used only with invalid_grant. The reason code refines the error code and never contradicts it.

Grammar, exactly: error_description matches ^[a-z_]+(: .*)?$. A client treats anything else as "no reason". The text after the colon is printable ASCII without " or \ (RFC 6749 §5.2), and never contains a claim value (sub, upstream_subject, act, jti).

Refusals added by later work. Each pull request that adds a redemption refusal gives it a reason code by this grammar. If this issue has not landed yet, it adds the row here instead:

Refusal Added by Response
A well-formed resource claim that does not cover the requested resource "ID-JAG redemption: compare the requested resource with the assertion's resource claim, and decide the default when it is omitted" (#6892) 400 invalid_target
A malformed resource claim "ID-JAG redemption: compare the requested resource with the assertion's resource claim, and decide the default when it is omitted" (#6892) 400 invalid_grant, invalid_assertion
An aud array with more than one element "Delegated access: subject mapping at ID-JAG redemption" (#6887) 400 invalid_grant, invalid_assertion
upstream_subject missing or malformed, upstream issuer not allowed, wrong binding claim "Delegated access: subject mapping at ID-JAG redemption" (#6887) 400 invalid_grant, invalid_assertion
Unknown or ambiguous user (embedded mode) "Delegated access: subject mapping at ID-JAG redemption" (#6887) 400 access_denied, subject_unknown (the "subject not mapped" row above)
act.iss not allowed, or the actor policy denies "Delegated access: subject mapping at ID-JAG redemption" (#6887) 400 access_denied, actor_denied
Redemption not allowed for (issuer, client, resource) "Delegated access: subject mapping at ID-JAG redemption" (#6887) 400 access_denied, resource_denied
An ID-JAG with cnf redeemed by a resolve issuer "Delegated access: subject mapping at ID-JAG redemption" (#6887) 400 invalid_grant, invalid_assertion
Resolver unavailable "Delegated access: subject mapping at ID-JAG redemption" (#6887) 503 or server_error (the "storage unavailable" row above)

Existing per-subject allowlist refusals (subject_bindings). On the ID-JAG path these refuse a valid ID-JAG, so they follow the rule above:

Refusal Today After
The ID-JAG's subject is not listed in subject_bindings 400 invalid_grant, fosite text 400 access_denied, subject_unknown
The subject is listed, but not for the requested resource 400 invalid_target, no description 400 access_denied, resource_denied (draft -06 §4.4.1: MUST be access_denied "if none of the resources are acceptable")
The requested resource is outside the redeeming client's audiences 400 invalid_target, hint naming the resource 400 access_denied, resource_denied; the resource is not echoed

The plain RFC 7523 JWT-bearer grant, which is outside the ID-JAG profile, keeps today's codes for the two subject_bindings refusals. The client-audience check is shared with /authorize and RFC 8693 token exchange, which keep invalid_target; only ID-JAG redemption changes.

Behaviour change for clients that retry. Today every redemption refusal is invalid_grant with no reason code. A client that retries a reasonless invalid_grant once with a new ID-JAG, as Mecatl's broker does, stops retrying validation failures once they carry invalid_assertion, and stops retrying the refusals above once they are access_denied. Mecatl's design already intends both. The pull request states this in its user-facing section.

Change

Put the reason code at the start of error_description for each ID-JAG redemption refusal above. Keep any existing text after a colon.

Build each refusal as a literal error with the reason as its description, as the token-exchange handlers already do (exactReason). fosite's WithHint cannot be used: it puts fosite's default text first, so the reason would not lead. Apply it to the plain RFC 7523 JWT-bearer grant too, since the handlers share their assertion checks. That changes error_description (not error) for plain JWT-bearer clients; the pull request states it as a user-facing change.

Acceptance

  • Each refusal case returns the listed status and reason code.
  • A client that reads only the part of error_description before the first colon gets the reason code in every case.
  • Every refusal's error_description matches ^[a-z_]+(: .*)?$ and contains no claim value.
  • invalid_assertion appears only with invalid_grant.

Activity

  1. self-assigned this
    on Nov 3, 2026
  2. removed
    needs-triageIssue needs initial triage by a maintainer
    on Nov 3, 2026
  3. jhrozek commented on Nov 18, 2026

    @jhrozek
    Contributor

    One addition while implementing this: a refusal that isn't in the table above.

    If AS-2 can't get the assertion issuer's signing keys (the JWKS fetch fails, or the key set it gets back is empty or over the key limit), it now answers 503 temporarily_unavailable with error_description issuer_unavailable, not invalid_grant / invalid_assertion. An invalid_assertion would tell the broker the assertion can never be accepted, but the same ID-JAG would go through once the keys are reachable, so this follows the "storage unavailable" row rather than the validation one. An unknown kid that is still unknown after a key refresh stays invalid_assertion, so nothing about the assertion itself can produce the 503.

    Mecatl's broker already treats any 503 / temporarily_unavailable as a retryable UNAVAILABLE, so it needs no behaviour change; I'll add the reason to its design docs and known-reasons list.

  4. jhrozek commented on Nov 22, 2026

    @jhrozek
    Contributor

    Done in "Add reason codes to redemption refusals" (#7193). That PR referenced this issue without closing it. actor_denied arrives with the actor check in "Delegated access: subject mapping at ID-JAG redemption" (#6887), whose refusal table already lists it. consent_required belongs to "Delegated access: user approval at an external gateway" (#7158).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions