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

Usage of invalid_grant for password grant #1059

Closed
ThisIsAreku opened this issue Oct 10, 2019 · 1 comment
Closed

Usage of invalid_grant for password grant #1059

ThisIsAreku opened this issue Oct 10, 2019 · 1 comment

Comments

@ThisIsAreku
Copy link

In case of an authentication failure in password grant, the returned error is a invalid_grant (400)

$user = $this->userRepository->getUserEntityByUserCredentials(
$username,
$password,
$this->getIdentifier(),
$client
);
if ($user instanceof UserEntityInterface === false) {
$this->getEmitter()->emit(new RequestEvent(RequestEvent::USER_AUTHENTICATION_FAILED, $request));
throw OAuthServerException::invalidGrant();
}

I can't find any informations in RFC about invalid_credentials but thinks it's a more appropriate error in this case, and it's already defined in OAuthServerException

/**
* Invalid credentials error.
*
* @return static
*/
public static function invalidCredentials()
{
return new static('The user credentials were incorrect.', 6, 'invalid_credentials', 401);
}

Or maybe I should throw it myself in my implementation of UserRepositoryInterface ?

@Sephster
Copy link
Member

We returned invalid_credentials in version 7 but found this did not comply with the OAuth 2 RFC. Unless stated, servers should return a 400 response. The invalid_grant response should be returned if client_authentication fails. Details for this change can be found here.

I hope this clarifies matters but if you'd like to discuss further please feel free to respond. Marking this as closed unless further information comes to light.

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

No branches or pull requests

2 participants