fix: remove Authorization header for public clients in OAuth2 token exchange #61
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.
Summary
Public OAuth2 clients using PKCE should not send Authorization headers during token exchange per RFC 7636. This was causing token refresh failures with external OIDC providers like Authelia and Zitadel.
Changes
clientAuthnullable inTokenRequestandTokenRequestParamsTokenRequestRemoteOperation(only adds header whenclientAuthis non-null and non-empty)isTokenEndpointAuthMethodNone()helper method inOIDCServerConfigurationto detect public clientsLoginActivityto setclientAuth = nullfor public clients based ontoken_endpoint_auth_methodfrom OIDC discoveryAccountAuthenticatorrefresh token flow with same logic for consistent behaviorTesting
Tested with Authelia OIDC provider configured with
token_endpoint_auth_method: none. Both initial token exchange and token refresh now work correctly without sending the incorrect Authorization header.RFC Compliance
This change ensures compliance with RFC 7636 (PKCE) and RFC 6749 (OAuth 2.0), which specify that public clients should only send form parameters (client_id, code, code_verifier, redirect_uri, grant_type) during token exchange, with no Authorization header.
Related to #55