Skip to content

Commit

Permalink
[PM-4167] feat: add prfStatus property
Browse files Browse the repository at this point in the history
  • Loading branch information
coroiu committed Oct 5, 2023
1 parent e01e117 commit e6f5534
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bit.Core.Auth.Entities;
using Bit.Core.Auth.Enums;
using Bit.Core.Models.Api;

namespace Bit.Api.Auth.Models.Response.WebAuthn;
Expand All @@ -11,10 +12,10 @@ public WebAuthnCredentialResponseModel(WebAuthnCredential credential) : base(Res
{
Id = credential.Id.ToString();
Name = credential.Name;
SupportsPrf = credential.SupportsPrf;
PrfStatus = credential.GetPrfStatus();
}

public string Id { get; set; }
public string Name { get; set; }
public bool SupportsPrf { get; set; }
public WebAuthnPrfStatus PrfStatus { get; set; }
}
16 changes: 16 additions & 0 deletions src/Core/Auth/Entities/WebAuthnCredential.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.Auth.Enums;
using Bit.Core.Entities;
using Bit.Core.Utilities;

Expand Down Expand Up @@ -29,4 +30,19 @@ public void SetNewId()
{
Id = CoreHelpers.GenerateComb();
}


public WebAuthnPrfStatus GetPrfStatus()
{
if (SupportsPrf && EncryptedUserKey != null && EncryptedPrivateKey != null && EncryptedPublicKey != null)
{
return WebAuthnPrfStatus.Enabled;
}
else if (SupportsPrf)
{
return WebAuthnPrfStatus.Supported;
}

return WebAuthnPrfStatus.Unsupported;
}
}
8 changes: 8 additions & 0 deletions src/Core/Auth/Enums/WebAuthnPrfStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Bit.Core.Auth.Enums;

public enum WebAuthnPrfStatus
{
Enabled = 0,
Supported = 1,
Unsupported = 2
}

0 comments on commit e6f5534

Please sign in to comment.