Repository navigation
Accept client_secret_basic at the token endpoint - #229
Open
chefboyrdave21 wants to merge 1 commit into
Open
chefboyrdave21 wants to merge 1 commit into
chefboyrdave21 wants to merge 1 commit into
Conversation
The discovery document advertises client_secret_basic, but the token endpoint only looked for client_id in the request body. A confidential client that authenticates with an HTTP Basic Authorization header (the default for openid-client, which @inrupt/solid-client-authn-node uses) therefore got an ID token with "aud": null, which the client rejects, and its registration was never loaded, so the client_credentials grant always failed with 401. Read the client_id from the Basic header (form-urlencoded per RFC 6749 section 2.3.1) when it is not in the body, both for loading the client registration and for the audience of the issued tokens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The discovery document advertises
client_secret_basic, but the token endpoint only readsclient_idfrom the request body. A confidential client that authenticates with an HTTP BasicAuthorizationheader (the default ofopenid-client, used by@inrupt/solid-client-authn-node):"aud": null, which the client rejects (aud mismatch, expected <client_id>, got: null);client_credentialsgrant always fails with 401 (the client is treated as public, and league/oauth2-server requires a confidential client for that grant).Fix
When
client_idis not in the body, read it from the Basic header (form-urlencoded per RFC 6749 §2.3.1), both for loading the client registration increateAuthServerConfig()and for the audience of the tokens intoken(). Requests that sendclient_idin the body behave as before.Tests
testTokenWithClientSecretBasicinServerControllerTest.Verification
Verified on Nextcloud 35.0.2 (PHP 8.5) behind a reverse proxy that terminates TLS, with
@inrupt/solid-client-authn-node5.0.3 /@inrupt/solid-client4.0.0 and in a headless browser. The unit suite passes in a Nextcloud 35 container. With this change (together with the other small fixes I opened) a Node.js app completes the authorization code flow with DPoP.🤖 Generated with Claude Code