2025-07-08 10:25:41 -04:00
|
|
|
|
// FIXME: Update this file to be null safe and then delete the line below
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
|
|
using Bit.Core.Auth.Enums;
|
2023-04-14 13:25:56 -04:00
|
|
|
|
using Bit.Core.Entities;
|
2021-12-14 15:05:07 +00:00
|
|
|
|
using Bit.Core.Models.Api;
|
2017-06-19 22:08:10 -04:00
|
|
|
|
|
2023-04-14 13:25:56 -04:00
|
|
|
|
namespace Bit.Api.Auth.Models.Response.TwoFactor;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2017-06-19 22:08:10 -04:00
|
|
|
|
public class TwoFactorYubiKeyResponseModel : ResponseModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public TwoFactorYubiKeyResponseModel(User user)
|
|
|
|
|
|
: base("twoFactorYubiKey")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (user == null)
|
|
|
|
|
|
{
|
2020-03-27 14:36:37 -04:00
|
|
|
|
throw new ArgumentNullException(nameof(user));
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-27 14:36:37 -04:00
|
|
|
|
var provider = user.GetTwoFactorProvider(TwoFactorProviderType.YubiKey);
|
|
|
|
|
|
if (provider?.MetaData != null && provider.MetaData.Count > 0)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2017-06-19 22:08:10 -04:00
|
|
|
|
Enabled = provider.Enabled;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2025-06-02 18:18:28 +02:00
|
|
|
|
if (provider.MetaData.TryGetValue("Key1", out var key1))
|
2017-06-19 22:08:10 -04:00
|
|
|
|
{
|
2025-06-02 18:18:28 +02:00
|
|
|
|
Key1 = (string)key1;
|
2017-06-19 22:08:10 -04:00
|
|
|
|
}
|
2025-06-02 18:18:28 +02:00
|
|
|
|
if (provider.MetaData.TryGetValue("Key2", out var key2))
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
2025-06-02 18:18:28 +02:00
|
|
|
|
Key2 = (string)key2;
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
2025-06-02 18:18:28 +02:00
|
|
|
|
if (provider.MetaData.TryGetValue("Key3", out var key3))
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2025-06-02 18:18:28 +02:00
|
|
|
|
Key3 = (string)key3;
|
2022-08-29 14:53:16 -04:00
|
|
|
|
}
|
2025-06-02 18:18:28 +02:00
|
|
|
|
if (provider.MetaData.TryGetValue("Key4", out var key4))
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
2025-06-02 18:18:28 +02:00
|
|
|
|
Key4 = (string)key4;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2025-06-02 18:18:28 +02:00
|
|
|
|
if (provider.MetaData.TryGetValue("Key5", out var key5))
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2025-06-02 18:18:28 +02:00
|
|
|
|
Key5 = (string)key5;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2025-06-02 18:18:28 +02:00
|
|
|
|
if (provider.MetaData.TryGetValue("Nfc", out var nfc))
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2025-06-02 18:18:28 +02:00
|
|
|
|
Nfc = (bool)nfc;
|
2017-06-19 22:08:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-08-29 16:06:55 -04:00
|
|
|
|
else
|
2017-06-29 12:34:10 -04:00
|
|
|
|
{
|
|
|
|
|
|
Enabled = false;
|
|
|
|
|
|
}
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2017-06-29 12:34:10 -04:00
|
|
|
|
public bool Enabled { get; set; }
|
2017-06-19 22:08:10 -04:00
|
|
|
|
public string Key1 { get; set; }
|
|
|
|
|
|
public string Key2 { get; set; }
|
|
|
|
|
|
public string Key3 { get; set; }
|
|
|
|
|
|
public string Key4 { get; set; }
|
|
|
|
|
|
public string Key5 { get; set; }
|
2017-06-29 12:34:10 -04:00
|
|
|
|
public bool Nfc { get; set; }
|
2017-06-19 22:08:10 -04:00
|
|
|
|
}
|