Skip to content

Accept issuer as client assertion audience - #6946

Merged
rdimitrov merged 1 commit into
removed-client-filterfrom
stable-client-v2-a
Oct 26, 2026
Merged

rdimitrov merged 1 commit into
removed-client-filterfrom
stable-client-v2-a

Conversation

@jhrozek

@jhrozek jhrozek commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Why: the token endpoint only accepted the token endpoint URL as the aud of a private_key_jwt client assertion. draft-ietf-oauth-rfc7523bis section 4 requires the issuer, so clients that follow the draft got invalid_client.
  • What: the token endpoint now accepts either the issuer or the token endpoint URL as aud, as a string or inside an array. The device authorization endpoint accepts the same values. fosite gets the list of accepted audiences through a small Configurator wrapper, built once when the provider is created. The wrapper overrides only GetTokenURLs.
  • The aud checks for JWT-bearer, ID-JAG and SPIFFE JWT-SVID are unchanged. fosite reads GetTokenURLs only in client authentication and in its rfc7523 handler, and ToolHive doesn't use that handler.
  • Accepting the token endpoint URL, or an aud array with more than one value, doesn't meet the draft. Both are deprecated, and a later release will require the issuer as the only value.

Stacked on #6945. Review only the top commit (a03d7e30d).

Refs #6893

Type of change

  • New feature

Test plan

  • Unit tests (task test) — not yet run on this branch

New integration test TestIntegration_PrivateKeyJWTClientAssertionAudience registers a private_key_jwt client through DCR. It then sends token-exchange requests with these assertions:

  • aud = issuer: accepted
  • aud = token endpoint URL: accepted
  • aud = an unrelated value: refused with invalid_client
  • typ = client-authentication+jwt: accepted

A separate subtest sends an assertion with aud = issuer to the device authorization endpoint.

Does this introduce a user-facing change?

Yes.

  • Before: a private_key_jwt client assertion whose aud was the issuer (for example https://auth.example.com) got 401 invalid_client. Only https://auth.example.com/oauth/token was accepted.
  • After: both are accepted, as a string or inside an array. Using the token endpoint URL, or an aud array with more than one value, is deprecated.

Special notes for reviewers

  • Accepting the issuer doesn't weaken client authentication. The assertion must still have iss == sub == client_id, a valid signature from the client's registered JWKS, and a jti that hasn't been used before. aud is compared as an exact string, so an assertion for another issuer on the same host is still refused.
  • The wrapper embeds *fosite.Config. The client authentication strategy and the endpoint handlers set on that config after NewOAuth2Provider therefore still reach the provider.
  • Planned follow-ups:
    • make the device-endpoint subtest assert exactly 400 unauthorized_client
    • add test cases for an aud array with more than one value and for a trailing-slash issuer
    • consider a log line when a client uses a deprecated aud form

🤖 Generated with Claude Code

Before this change only the token endpoint URL was accepted as the
aud of a private_key_jwt client assertion. draft-ietf-oauth-rfc7523bis
section 4 requires the issuer, so clients following the draft were
refused.

Accept the issuer alongside the token endpoint URL, as a string or as
an array containing either. The audience set is supplied to fosite
through a Configurator wrapper built once at startup. Accepting the
token endpoint URL, and an aud array with several values, do not meet
the draft and are deprecated. A later release will require the issuer
as the sole value.

JWT-bearer, ID-JAG and SPIFFE JWT-SVID audience checks are
unchanged.

Refs #6893

Co-authored-by: Mecatl <[email protected]>
@github-actions github-actions Bot added the size/S Small PR: 100-299 lines changed label Oct 26, 2026
@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.05%. Comparing base (7deef4f) to head (a03d7e3).

Additional details and impacted files
@@                  Coverage Diff                   @@
##           removed-client-filter    #6946   +/-   ##
======================================================
  Coverage                  80.04%   80.05%           
======================================================
  Files                        840      841    +1     
  Lines                      85441    85445    +4     
======================================================
+ Hits                       68394    68402    +8     
+ Misses                     17042    17038    -4     
  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.

@rdimitrov
rdimitrov merged commit 55f4049 into removed-client-filter Oct 26, 2026
43 of 44 checks passed
@rdimitrov
rdimitrov deleted the stable-client-v2-a branch October 26, 2026 16:40
jhrozek added a commit that referenced this pull request Oct 26, 2026
* Stamp clients written from configuration

Rows written by ReconcileConfiguredClient now carry a configured
stamp: a stored field on Redis and a side map on memory, returned to
readers as a marker on the client. Rows written by RegisterClient or
the CIMD upsert never carry it, RegisterClient refuses a client that
does, and reconcile refuses client types it cannot mark back on read.

Startup reconciles configured clients into storage, but nothing ever
deletes a removed client's row, so on Redis a delegate removed from
config keeps authenticating with its stored secret or keys. Telling
those rows apart from rows an embedder wrote itself is the first step
to refusing them. Nothing reads the stamp yet, so behaviour is
unchanged.

Co-authored-by: Mecatl <[email protected]>

* Admit configured clients by stamp

Removing a delegate client from config did not revoke it. Startup
reconciles configured clients into storage, but nothing deletes a
removed client's row, so on Redis the client kept authenticating with
its stored secret or keys and kept its grants.

A new admission layer, ClientAdmissionStorage, sits directly over the
caller's storage, below the CIMD and SPIFFE decorators, and overrides
only GetClient. It classifies each stored row by what the row shows:
a SPIFFE placeholder is never served, a configured row (the stamp, or
the legacy delegate shape older releases wrote) is served only while
its ID is a configured delegate, and registered (DCR or CIMD) and
unmarked rows are always served. A row that does not pass is answered
exactly like an unknown client, with one WARN per client ID. Admission
never deletes or rewrites a row.

The callback's CIMD rate-limit fallback now reads through
ClientStoreBelowCIMD, which stops at the admission layer, instead of
reaching the raw backend.

A test removes clients between two starts on the same Redis and
probes every route that takes a client. One token endpoint probe
covers all grants, because a second test requires every registered
token handler to authenticate the client whenever credentials are
present. The route check fails if the router gains a route no probe
covers; the pending consent, callback and device verification routes
are listed as exempt for now.

User-facing: a delegate client removed from config gets invalid_client
after a restart, where it used to keep working on Redis. Clients an
embedder writes with RegisterClient are served as before, unless they
match the legacy delegate shape. The stored row is not deleted; to
remove it, DEL the client key. Already-issued access tokens stay valid
until they expire.

Co-authored-by: Mecatl <[email protected]>

* Refuse pending requests for removed clients

Client admission hides a removed delegate from every client lookup,
but a pending authorization or device request created before the
restart only carries a client ID. Consent and the upstream callback
fell back to an empty client when the lookup failed, so such a request
could still go upstream, and device verification never looked the
client up again.

Consent, the upstream callback (including its error branch) and the
three device verification steps now refuse a pending request whose
client no longer resolves, before anything is sent upstream or
authorized. buildAuthorizeRequesterFromPending returns the client
lookup error instead of continuing without a client, and one shared
helper decides what counts as an unresolved client, logged at DEBUG.
Storage and transport failures still answer 500.

The removal test now probes the consent, callback and device
verification routes instead of listing them as exempt.

User-facing: a pending consent or upstream callback for a removed
client gets a plain-text 400 containing invalid_client, and the
device verification page refuses the request. Nothing is sent
upstream and the device request is never authorized.

Co-authored-by: Mecatl <[email protected]>

* Accept issuer as client assertion audience (#6946)

Before this change only the token endpoint URL was accepted as the
aud of a private_key_jwt client assertion. draft-ietf-oauth-rfc7523bis
section 4 requires the issuer, so clients following the draft were
refused.

Accept the issuer alongside the token endpoint URL, as a string or as
an array containing either. The audience set is supplied to fosite
through a Configurator wrapper built once at startup. Accepting the
token endpoint URL, and an aud array with several values, do not meet
the draft and are deprecated. A later release will require the issuer
as the sole value.

JWT-bearer, ID-JAG and SPIFFE JWT-SVID audience checks are
unchanged.

Refs #6893

Co-authored-by: Mecatl <[email protected]>

* Refuse device confirm without upstream tokens

A pending device confirmation without upstream tokens is corrupt
data. The confirm step looked up the client with an empty ID, so
the user got a "no longer valid" page that blames the device
request instead of the stored record.

The confirm step now answers 500 for such a record before the
client lookup, as it did before the lookup was added. Deny still
works, because it runs first.

Co-authored-by: Mecatl <[email protected]>

---------

Co-authored-by: Mecatl <[email protected]>
@github-actions github-actions Bot mentioned this pull request Oct 27, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants