Always validate auth code clients, even when public #1036
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.
The validateClient method is called for public clients when using the refresh_token and password grant type and the interface allows passing a null secret, so it's not necessary to skip calling the method for the authorization_code grant type.
When I saw that we skipped calling
validateSecret
for public clients in the auth code grant and that the$mustValidateSecret
parameter was removed for 8.0 I assumed that meantvalidateClient
would no longer be called for public clients. I later realizedvalidateClient
is called for public clients when using the password or refresh token grant.If
validateClient
is called for public clients for the other grant types you will need to do something likereturn !$client->isConfidential() || hash_equals($client->getSecret(), $clientSecret)
anyway, so it doesn't seem necessary to skip calling it here.Hopefully by removing the unnecessary check it will be less misleading to other developers and increase the likelihood that they handle public clients appropriately in
validateClient
.The
validateClient
method also callsvalidateRedirectUri
which emits aCLIENT_AUTHENTICATION_FAILED
event if validation fails. ThevalidateAuthorizationCode
also validates the redirect URI but does not emit an event. CallingvalidateClient
regardless will ensure the event is consistently fired for invalid redirect URIs just in case someone is relying on it.