Skip to content

Set audience on DCR clients for refresh token support - #3796

Merged
jhrozek merged 1 commit into
mainfrom
fix/dcr-audience-whitelist
Feb 13, 2026
Merged

Set audience on DCR clients for refresh token support#3796
jhrozek merged 1 commit into
mainfrom
fix/dcr-audience-whitelist

Conversation

@jhrozek

@jhrozek jhrozek commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

DCR-registered clients had no Audience field set on the fosite DefaultClient. During refresh token requests with resource= (RFC 8707), Fosite validates the original session's granted audience against the client's registered audience whitelist. With an empty whitelist, all refresh token requests failed with "has not been whitelisted".

Pass AllowedAudiences from the server config to registration.New() so DCR clients inherit the server's allowed audiences.

Fixes: #3777

DCR-registered clients had no Audience field set on the fosite
DefaultClient. During refresh token requests with resource= (RFC 8707),
Fosite validates the original session's granted audience against the
client's registered audience whitelist. With an empty whitelist, all
refresh token requests failed with "has not been whitelisted".

Pass AllowedAudiences from the server config to registration.New() so
DCR clients inherit the server's allowed audiences.

Fixes: #3777
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label Feb 11, 2026
@codecov

codecov Bot commented Feb 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.77%. Comparing base (c8f2254) to head (c3ad3c4).
⚠️ Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3796      +/-   ##
==========================================
- Coverage   66.78%   66.77%   -0.01%     
==========================================
  Files         437      437              
  Lines       43002    43007       +5     
==========================================
  Hits        28718    28718              
- Misses      12078    12085       +7     
+ Partials     2206     2204       -2     

☔ View full report in Codecov by Sentry.
📢 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.

@jhrozek
jhrozek merged commit d343edf into main Feb 13, 2026
36 checks passed
@jhrozek
jhrozek deleted the fix/dcr-audience-whitelist branch February 13, 2026 00:12
alex-feel added a commit to alex-feel/toolhive that referenced this pull request Sep 3, 2026
CIMD-resolved clients were built with an empty audience list, so
fosite's DefaultAudienceMatchingStrategy rejected every refresh_token
grant with "has not been whitelisted by the OAuth 2.0 Client".
The authorization_code grant was unaffected because that path never
validates audience, so the failure only surfaced on refresh, roughly
an access-token lifetime after the first sign-in.
CIMDDecoratorConfig now carries AllowedAudiences, threaded from the
server's own AllowedAudiences at construction, and buildFositeClient
grants that list to every resolved client, mirroring how DCR clients
already inherit the server's AllowedAudiences (stacklok#3796).

Fixes: stacklok#6489
blkt pushed a commit that referenced this pull request Sep 3, 2026
CIMD-resolved clients were built with an empty audience list, so
fosite's DefaultAudienceMatchingStrategy rejected every refresh_token
grant with "has not been whitelisted by the OAuth 2.0 Client".
The authorization_code grant was unaffected because that path never
validates audience, so the failure only surfaced on refresh, roughly
an access-token lifetime after the first sign-in.
CIMDDecoratorConfig now carries AllowedAudiences, threaded from the
server's own AllowedAudiences at construction, and buildFositeClient
grants that list to every resolved client, mirroring how DCR clients
already inherit the server's AllowedAudiences (#3796).

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

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embedded auth server: DCR clients missing audience whitelist breaks refresh token with resource parameter

2 participants