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

Always validate the client and determine if it handles the grant type #1420

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

hafezdivandari
Copy link

@hafezdivandari hafezdivandari commented Jun 30, 2024

Fixes #1174
Fixes #1369
Related to #1073
Closes #1036

This PR can be considered as a security enhancement and does 2 main changes:

  1. Always validate client:
    • The "auth code" grant - Unlike all other grants - calls AbstractGrant::validateClient() only if the client is confidential. This PR fixes this inconsistent behavior and makes the server always call AbstractGrant::validateClient().
    • The "auth code" and "client credential" grants unnecessarily call AbstractGrant::getClientEntityOrFail() twice instead of just using the AbstractGrant::validateClient() return value, this PR fixes that.
    • All grants except "client credentials" grant can be non-confidential. So this PR fixes the example implementation of ClientRepository::validateClient(): validate the client secret only if the client is confidential. It's already implemented this way on most community integrations:
  2. New ClientEntityInterface::hasGrantType() function:
    • This function is implemented on ClientTrait that returns true by default to avoid BC breaking changes.
    • Currently there is no way to check if the client handles the grant type before proceeding the request, e.g. We don't want to make auth code on "auth code grant" or make device code on "device code auth" grant or response with the access token on "implicit token" grant if the specified client doesn't handle the grant type. This PR makes this possible to avoid handling the requested grant type if the specified client doesn't supports that.
    • It also makes it possible for us to disable issuing refresh token if the client doesn't handle this grant.

@hafezdivandari hafezdivandari changed the title Always validate client Always validate the client and determine if it handles the grant type Oct 1, 2024
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.

RefreshTokenGrant requires client_secret also for non-confidential clients Add Unauthorized_Client support
1 participant