1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-06-26 10:36:21 +02:00
bitwarden-mobile/src/Core/Utilities/Fido2/Fido2UserVerificationPreference.cs
Federico Maccaroni 4292542155
[PM-6466] Implement passkeys User Verification (#3044)
* PM-6441 Implement passkeys User Verification

* PM-6441 Reorganized UserVerificationMediatorService so everything is not in the same file

* PM-6441 Fix Unit tests

* PM-6441 Refactor UserVerification on Fido2Authenticator and Client services to be of an enum type so we can see which specific preference the RP sent and to be passed into the user verification mediator service to perform the correct flow depending on that. Also updated Unit tests.

* PM-6441 Changed user verification logic a bit so if preference is Preferred and the app has the ability to verify the user then enforce required UV and fix issue on on Discouraged to take into account MP reprompt
2024-03-06 12:32:39 -03:00

40 lines
1.1 KiB
C#

#nullable enable
using Bit.Core.Enums;
namespace Bit.Core.Utilities.Fido2
{
public enum Fido2UserVerificationPreference
{
Discouraged,
Preferred,
Required
}
public static class Fido2UserVerificationPreferenceExtensions
{
public static Fido2UserVerificationPreference ToFido2UserVerificationPreference(string? preference)
{
switch (preference)
{
case "required":
return Fido2UserVerificationPreference.Required;
case "discouraged":
return Fido2UserVerificationPreference.Discouraged;
default:
return Fido2UserVerificationPreference.Preferred;
}
}
public static Fido2UserVerificationPreference GetUserVerificationPreferenceFrom(Fido2UserVerificationPreference preference, CipherRepromptType repromptType)
{
if (repromptType != CipherRepromptType.None)
{
return Fido2UserVerificationPreference.Required;
}
return preference;
}
}
}