mirror of
https://github.com/bitwarden/server.git
synced 2025-06-19 18:38:03 -05:00

* [PM-4167] feat: add support for `SupportsPrf` * [PM-4167] feat: add `prfStatus` property * [PM-4167] feat: add support for storing PRF keys * [PM-4167] fix: allow credentials to be created without encryption support * [PM-4167] fix: broken test * [PM-4167] chore: remove whitespace * [PM-4167] fix: controller test * [PM-4167] chore: improve readability of `GetPrfStatus` * [PM-4167] fix: make prf optional * [PM-4167] fix: commit missing controller change * [PM-4167] fix: tests
52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Bit.Core.Auth.Enums;
|
|
using Bit.Core.Entities;
|
|
using Bit.Core.Utilities;
|
|
|
|
namespace Bit.Core.Auth.Entities;
|
|
|
|
public class WebAuthnCredential : ITableObject<Guid>
|
|
{
|
|
public Guid Id { get; set; }
|
|
public Guid UserId { get; set; }
|
|
[MaxLength(50)]
|
|
public string Name { get; set; }
|
|
[MaxLength(256)]
|
|
public string PublicKey { get; set; }
|
|
[MaxLength(256)]
|
|
public string CredentialId { get; set; }
|
|
public int Counter { get; set; }
|
|
[MaxLength(20)]
|
|
public string Type { get; set; }
|
|
public Guid AaGuid { get; set; }
|
|
[MaxLength(2000)]
|
|
public string EncryptedUserKey { get; set; }
|
|
[MaxLength(2000)]
|
|
public string EncryptedPrivateKey { get; set; }
|
|
[MaxLength(2000)]
|
|
public string EncryptedPublicKey { get; set; }
|
|
public bool SupportsPrf { get; set; }
|
|
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
|
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
|
|
|
public void SetNewId()
|
|
{
|
|
Id = CoreHelpers.GenerateComb();
|
|
}
|
|
|
|
public WebAuthnPrfStatus GetPrfStatus()
|
|
{
|
|
if (!SupportsPrf)
|
|
{
|
|
return WebAuthnPrfStatus.Unsupported;
|
|
}
|
|
|
|
if (EncryptedUserKey != null && EncryptedPrivateKey != null && EncryptedPublicKey != null)
|
|
{
|
|
return WebAuthnPrfStatus.Enabled;
|
|
}
|
|
|
|
return WebAuthnPrfStatus.Supported;
|
|
}
|
|
}
|