1
0
mirror of https://github.com/bitwarden/server synced 2026-01-08 19:43:34 +00:00

[PM-6303] Add duo state to 2fa (#3806)

* add duo state to 2fa

* Id to UserId
This commit is contained in:
Jake Fink
2024-02-14 18:00:46 -05:00
committed by GitHub
parent 744d21ec5e
commit d99d3b8380
3 changed files with 65 additions and 5 deletions

View File

@@ -0,0 +1,37 @@
using Bit.Core.Entities;
using Bit.Core.Tokens;
using Newtonsoft.Json;
namespace Bit.Core.Auth.Models.Business.Tokenables;
public class DuoUserStateTokenable : Tokenable
{
public const string ClearTextPrefix = "BwDuoUserId";
public const string DataProtectorPurpose = "DuoUserIdTokenDataProtector";
public const string TokenIdentifier = "DuoUserIdToken";
public string Identifier { get; set; } = TokenIdentifier;
public Guid UserId { get; set; }
public override bool Valid => Identifier == TokenIdentifier &&
UserId != default;
[JsonConstructor]
public DuoUserStateTokenable()
{
}
public DuoUserStateTokenable(User user)
{
UserId = user?.Id ?? default;
}
public bool TokenIsValid(User user)
{
if (UserId == default || user == null)
{
return false;
}
return UserId == user.Id;
}
}