2022-09-26 13:21:13 -04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
|
using System.Reflection;
|
2023-04-14 13:25:56 -04:00
|
|
|
|
using Bit.Core.Auth.Entities;
|
2025-01-29 12:08:29 -05:00
|
|
|
|
using Bit.Core.Enums;
|
2022-09-26 13:21:13 -04:00
|
|
|
|
using Bit.Core.Models.Api;
|
|
|
|
|
|
|
2023-04-14 13:25:56 -04:00
|
|
|
|
namespace Bit.Api.Auth.Models.Response;
|
2022-09-26 13:21:13 -04:00
|
|
|
|
|
|
|
|
|
|
public class AuthRequestResponseModel : ResponseModel
|
|
|
|
|
|
{
|
2022-10-04 11:06:01 -04:00
|
|
|
|
public AuthRequestResponseModel(AuthRequest authRequest, string vaultUri, string obj = "auth-request")
|
2022-09-26 13:21:13 -04:00
|
|
|
|
: base(obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (authRequest == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(authRequest));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-14 17:18:26 +02:00
|
|
|
|
Id = authRequest.Id;
|
2022-09-26 13:21:13 -04:00
|
|
|
|
PublicKey = authRequest.PublicKey;
|
2025-01-29 12:08:29 -05:00
|
|
|
|
RequestDeviceTypeValue = authRequest.RequestDeviceType;
|
2022-09-26 13:21:13 -04:00
|
|
|
|
RequestDeviceType = authRequest.RequestDeviceType.GetType().GetMember(authRequest.RequestDeviceType.ToString())
|
|
|
|
|
|
.FirstOrDefault()?.GetCustomAttribute<DisplayAttribute>()?.GetName();
|
|
|
|
|
|
RequestIpAddress = authRequest.RequestIpAddress;
|
|
|
|
|
|
Key = authRequest.Key;
|
|
|
|
|
|
MasterPasswordHash = authRequest.MasterPasswordHash;
|
|
|
|
|
|
CreationDate = authRequest.CreationDate;
|
2022-11-29 12:49:42 +00:00
|
|
|
|
RequestApproved = authRequest.Approved ?? false;
|
2022-10-04 11:06:01 -04:00
|
|
|
|
Origin = new Uri(vaultUri).Host;
|
2022-11-15 14:17:42 +00:00
|
|
|
|
ResponseDate = authRequest.ResponseDate;
|
2022-09-26 13:21:13 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-14 17:18:26 +02:00
|
|
|
|
public Guid Id { get; set; }
|
2022-09-26 13:21:13 -04:00
|
|
|
|
public string PublicKey { get; set; }
|
2025-01-29 12:08:29 -05:00
|
|
|
|
public DeviceType RequestDeviceTypeValue { get; set; }
|
2022-09-26 13:21:13 -04:00
|
|
|
|
public string RequestDeviceType { get; set; }
|
|
|
|
|
|
public string RequestIpAddress { get; set; }
|
|
|
|
|
|
public string Key { get; set; }
|
|
|
|
|
|
public string MasterPasswordHash { get; set; }
|
|
|
|
|
|
public DateTime CreationDate { get; set; }
|
2022-11-15 14:17:42 +00:00
|
|
|
|
public DateTime? ResponseDate { get; set; }
|
2022-11-29 12:49:42 +00:00
|
|
|
|
public bool RequestApproved { get; set; }
|
2022-09-26 13:21:13 -04:00
|
|
|
|
public string Origin { get; set; }
|
|
|
|
|
|
}
|