Skip to content

Accept client_secret_basic at the token endpoint - #229

Open
chefboyrdave21 wants to merge 1 commit into
pdsinterop:mainfrom
smilinTux:fix/token-client-secret-basic
Open

chefboyrdave21 wants to merge 1 commit into
pdsinterop:mainfrom
smilinTux:fix/token-client-secret-basic

Conversation

@chefboyrdave21

Copy link
Copy Markdown

Problem

The discovery document advertises client_secret_basic, but the token endpoint only reads client_id from the request body. A confidential client that authenticates with an HTTP Basic Authorization header (the default of openid-client, used by @inrupt/solid-client-authn-node):

  • gets an ID token with "aud": null, which the client rejects (aud mismatch, expected <client_id>, got: null);
  • never has its registration loaded, so the client_credentials grant always fails with 401 (the client is treated as public, and league/oauth2-server requires a confidential client for that grant).

Fix

When client_id is not in the body, read it from the Basic header (form-urlencoded per RFC 6749 §2.3.1), both for loading the client registration in createAuthServerConfig() and for the audience of the tokens in token(). Requests that send client_id in the body behave as before.

Tests

testTokenWithClientSecretBasic in ServerControllerTest.

Verification

Verified on Nextcloud 35.0.2 (PHP 8.5) behind a reverse proxy that terminates TLS, with @inrupt/solid-client-authn-node 5.0.3 / @inrupt/solid-client 4.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

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant