mirror of
https://github.com/bitwarden/server.git
synced 2025-04-10 07:38:13 -05:00
[PM-5435] Handle Fido2VerificationException on WebAuthn 2FA (#3615)
* Handle Fido2VerificationException on WebAuthn 2FA * Linting!
This commit is contained in:
parent
37a22540a9
commit
94d665e6e9
@ -103,19 +103,27 @@ public class WebAuthnTokenProvider : IUserTwoFactorTokenProvider<User>
|
|||||||
// established ownership in this context.
|
// established ownership in this context.
|
||||||
IsUserHandleOwnerOfCredentialIdAsync callback = (args, cancellationToken) => Task.FromResult(true);
|
IsUserHandleOwnerOfCredentialIdAsync callback = (args, cancellationToken) => Task.FromResult(true);
|
||||||
|
|
||||||
var res = await _fido2.MakeAssertionAsync(clientResponse, options, webAuthCred.Item2.PublicKey, webAuthCred.Item2.SignatureCounter, callback);
|
try
|
||||||
|
{
|
||||||
|
var res = await _fido2.MakeAssertionAsync(clientResponse, options, webAuthCred.Item2.PublicKey, webAuthCred.Item2.SignatureCounter, callback);
|
||||||
|
|
||||||
provider.MetaData.Remove("login");
|
provider.MetaData.Remove("login");
|
||||||
|
|
||||||
// Update SignatureCounter
|
// Update SignatureCounter
|
||||||
webAuthCred.Item2.SignatureCounter = res.Counter;
|
webAuthCred.Item2.SignatureCounter = res.Counter;
|
||||||
|
|
||||||
var providers = user.GetTwoFactorProviders();
|
var providers = user.GetTwoFactorProviders();
|
||||||
providers[TwoFactorProviderType.WebAuthn].MetaData[webAuthCred.Item1] = webAuthCred.Item2;
|
providers[TwoFactorProviderType.WebAuthn].MetaData[webAuthCred.Item1] = webAuthCred.Item2;
|
||||||
user.SetTwoFactorProviders(providers);
|
user.SetTwoFactorProviders(providers);
|
||||||
await userService.UpdateTwoFactorProviderAsync(user, TwoFactorProviderType.WebAuthn, logEvent: false);
|
await userService.UpdateTwoFactorProviderAsync(user, TwoFactorProviderType.WebAuthn, logEvent: false);
|
||||||
|
|
||||||
|
return res.Status == "ok";
|
||||||
|
}
|
||||||
|
catch (Fido2VerificationException)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return res.Status == "ok";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HasProperMetaData(TwoFactorProvider provider)
|
private bool HasProperMetaData(TwoFactorProvider provider)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user