Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix client credentials comparing oauth_user_id and oauth_client_id #209

Merged
merged 1 commit into from
Feb 1, 2025

Conversation

ajgarlag
Copy link
Contributor

@ajgarlag ajgarlag commented Jan 21, 2025

In league/server-bundle version 0.8, when the client_credentials grant is used, the sub claim of the JWT is an empty string, but in version 0.9 is filled with the client ID.

In Section 5 of RFC9068, there is a recommendation to prevent the collision between sub claim values when the resource owner is either a client or a user.

So when client_id (derived from aud[0] claim) and user_id (derived from sub claim) are equal, the resource owner must be a client.

Fix #207

In `league/server-bundle` version `0.8`, when the client_credentials
grant is used, the `sub` claim of the JWT is an empty string, but in
version `0.9` is filled with the client ID.

In [Section 5](https://datatracker.ietf.org/doc/html/rfc9068#SecurityConsiderations)
of RFC9068, there is a recommendation to prevent the collision between `sub` claim values when the resource owner is either a client or a user.

So when client_id (derived from `aud[0]` claim) and user_id (derived from
`sub` claim) are equal, the resource owner must be a client.
@ajgarlag ajgarlag changed the title Fix client credentials Fix client credentials comparing oauth_user_id and oauth_client_id Jan 21, 2025
@chalasr
Copy link
Member

chalasr commented Feb 1, 2025

Thank you @ajgarlag.

@chalasr chalasr merged commit 161ba05 into thephpleague:master Feb 1, 2025
33 checks passed
@ajgarlag ajgarlag deleted the fix-client-credentials-0 branch February 16, 2025 17:36
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.

Apis with client_credentilas token: bad credentials response.
2 participants