mirror of
https://github.com/bitwarden/server.git
synced 2025-07-07 02:52:50 -05:00
[PM-4167] Add PRF attestation flow during passkey registration (#3339)
* [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
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Core.Auth.Enums;
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
@ -18,8 +19,11 @@ public class WebAuthnCredential : ITableObject<Guid>
|
||||
[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;
|
||||
@ -29,4 +33,19 @@ public class WebAuthnCredential : ITableObject<Guid>
|
||||
{
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
|
||||
public WebAuthnPrfStatus GetPrfStatus()
|
||||
{
|
||||
if (!SupportsPrf)
|
||||
{
|
||||
return WebAuthnPrfStatus.Unsupported;
|
||||
}
|
||||
|
||||
if (EncryptedUserKey != null && EncryptedPrivateKey != null && EncryptedPublicKey != null)
|
||||
{
|
||||
return WebAuthnPrfStatus.Enabled;
|
||||
}
|
||||
|
||||
return WebAuthnPrfStatus.Supported;
|
||||
}
|
||||
}
|
||||
|
8
src/Core/Auth/Enums/WebAuthnPrfStatus.cs
Normal file
8
src/Core/Auth/Enums/WebAuthnPrfStatus.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Bit.Core.Auth.Enums;
|
||||
|
||||
public enum WebAuthnPrfStatus
|
||||
{
|
||||
Enabled = 0,
|
||||
Supported = 1,
|
||||
Unsupported = 2
|
||||
}
|
Reference in New Issue
Block a user