mirror of
https://github.com/bitwarden/server.git
synced 2024-11-30 13:33:24 +01:00
Updated message to prevent enumeration.
This commit is contained in:
parent
b97a4d38ac
commit
bd46adce77
@ -26,13 +26,13 @@ internal class AssertWebAuthnLoginCredentialCommand : IAssertWebAuthnLoginCreden
|
||||
{
|
||||
if (!GuidUtilities.TryParseBytes(assertionResponse.Response.UserHandle, out var userId))
|
||||
{
|
||||
throw new BadRequestException("Invalid credential.");
|
||||
ThrowInvalidCredentialException();
|
||||
}
|
||||
|
||||
var user = await _userRepository.GetByIdAsync(userId);
|
||||
if (user == null)
|
||||
{
|
||||
throw new BadRequestException("Invalid credential.");
|
||||
ThrowInvalidCredentialException();
|
||||
}
|
||||
|
||||
var userCredentials = await _webAuthnCredentialRepository.GetManyByUserIdAsync(user.Id);
|
||||
@ -40,7 +40,7 @@ internal class AssertWebAuthnLoginCredentialCommand : IAssertWebAuthnLoginCreden
|
||||
var credential = userCredentials.FirstOrDefault(c => c.CredentialId == assertedCredentialId);
|
||||
if (credential == null)
|
||||
{
|
||||
throw new BadRequestException("Invalid credential.");
|
||||
ThrowInvalidCredentialException();
|
||||
}
|
||||
|
||||
// Always return true, since we've already filtered the credentials after user id
|
||||
@ -55,7 +55,7 @@ internal class AssertWebAuthnLoginCredentialCommand : IAssertWebAuthnLoginCreden
|
||||
}
|
||||
catch (Fido2VerificationException)
|
||||
{
|
||||
throw new BadRequestException("Unable to verify credential.");
|
||||
ThrowInvalidCredentialException();
|
||||
}
|
||||
|
||||
// Update SignatureCounter
|
||||
@ -64,9 +64,14 @@ internal class AssertWebAuthnLoginCredentialCommand : IAssertWebAuthnLoginCreden
|
||||
|
||||
if (assertionVerificationResult.Status != "ok")
|
||||
{
|
||||
throw new BadRequestException("Invalid credential.");
|
||||
ThrowInvalidCredentialException();
|
||||
}
|
||||
|
||||
return (user, credential);
|
||||
}
|
||||
|
||||
private void ThrowInvalidCredentialException()
|
||||
{
|
||||
throw new BadRequestException("Invalid credential.");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user