mirror of
https://github.com/bitwarden/server.git
synced 2026-01-31 22:23:18 +08:00
* Added migrations for sqlserver and mysql * Added migrations for postgres * renamed mysql migration script to make naming uniform * introduced approved field to the update auth request controller;This change would keep track of denied passwordless requests * Recreated the authRequestView, introduced the approved field to the create procedure and updated the response model * Formatted code * fixed incorrect syntax in the AuthRequest_Create.sql SP
43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Bit.Core.Utilities;
|
|
|
|
namespace Bit.Core.Entities;
|
|
|
|
public class AuthRequest : ITableObject<Guid>
|
|
{
|
|
public Guid Id { get; set; }
|
|
public Guid UserId { get; set; }
|
|
public Enums.AuthRequestType Type { get; set; }
|
|
[MaxLength(50)]
|
|
public string RequestDeviceIdentifier { get; set; }
|
|
public Enums.DeviceType RequestDeviceType { get; set; }
|
|
[MaxLength(50)]
|
|
public string RequestIpAddress { get; set; }
|
|
public string RequestFingerprint { get; set; }
|
|
public Guid? ResponseDeviceId { get; set; }
|
|
[MaxLength(25)]
|
|
public string AccessCode { get; set; }
|
|
public string PublicKey { get; set; }
|
|
public string Key { get; set; }
|
|
public string MasterPasswordHash { get; set; }
|
|
public bool? Approved { get; set; }
|
|
public DateTime CreationDate { get; set; } = DateTime.UtcNow;
|
|
public DateTime? ResponseDate { get; set; }
|
|
public DateTime? AuthenticationDate { get; set; }
|
|
|
|
public void SetNewId()
|
|
{
|
|
Id = CoreHelpers.GenerateComb();
|
|
}
|
|
|
|
public bool IsSpent()
|
|
{
|
|
return ResponseDate.HasValue || AuthenticationDate.HasValue || GetExpirationDate() < DateTime.UtcNow;
|
|
}
|
|
|
|
public DateTime GetExpirationDate()
|
|
{
|
|
return CreationDate.AddMinutes(15);
|
|
}
|
|
}
|