mirror of https://github.com/abpframework/abp.git
15 changed files with 453 additions and 4 deletions
@ -0,0 +1,9 @@ |
|||
namespace Volo.Abp.Identity; |
|||
|
|||
public static class IdentityUserPasskeyConsts |
|||
{ |
|||
/// <summary>
|
|||
/// Default value: 1024
|
|||
/// </summary>
|
|||
public static int MaxCredentialIdLength { get; set; } = 1024; |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.Identity; |
|||
|
|||
/// <summary>
|
|||
/// Represents data associated with a passkey.
|
|||
/// </summary>
|
|||
public class IdentityPasskeyData |
|||
{ |
|||
/// <summary>
|
|||
/// Gets or sets the public key associated with this passkey.
|
|||
/// </summary>
|
|||
public virtual byte[] PublicKey { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the friendly name for this passkey.
|
|||
/// </summary>
|
|||
public virtual string? Name { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the time this passkey was created.
|
|||
/// </summary>
|
|||
public virtual DateTimeOffset CreatedAt { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the signature counter for this passkey.
|
|||
/// </summary>
|
|||
public virtual uint SignCount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the transports supported by this passkey.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// See <see href="https://www.w3.org/TR/webauthn-3/#enumdef-authenticatortransport"/>.
|
|||
/// </remarks>
|
|||
public virtual string[] Transports { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets whether the passkey has a verified user.
|
|||
/// </summary>
|
|||
public virtual bool IsUserVerified { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets whether the passkey is eligible for backup.
|
|||
/// </summary>
|
|||
public virtual bool IsBackupEligible { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets whether the passkey is currently backed up.
|
|||
/// </summary>
|
|||
public virtual bool IsBackedUp { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the attestation object associated with this passkey.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// See <see href="https://www.w3.org/TR/webauthn-3/#attestation-object"/>.
|
|||
/// </remarks>
|
|||
public virtual byte[] AttestationObject { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the collected client data JSON associated with this passkey.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// See <see href="https://www.w3.org/TR/webauthn-3/#dictdef-collectedclientdata"/>.
|
|||
/// </remarks>
|
|||
public virtual byte[] ClientDataJson { get; set; } |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
using System; |
|||
using Volo.Abp.Domain.Entities; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace Volo.Abp.Identity; |
|||
|
|||
/// <summary>
|
|||
/// Represents a passkey credential for a user in the identity system.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// See <see href="https://www.w3.org/TR/webauthn-3/#credential-record"/>.
|
|||
/// </remarks>
|
|||
public class IdentityUserPasskey : Entity, IMultiTenant |
|||
{ |
|||
public virtual Guid? TenantId { get; protected set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the primary key of the user that owns this passkey.
|
|||
/// </summary>
|
|||
public virtual Guid UserId { get; protected set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the credential ID for this passkey.
|
|||
/// </summary>
|
|||
public virtual byte[] CredentialId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets additional data associated with this passkey.
|
|||
/// </summary>
|
|||
public virtual IdentityPasskeyData Data { get; set; } |
|||
|
|||
protected IdentityUserPasskey() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public IdentityUserPasskey( |
|||
Guid userId, |
|||
byte[] credentialId, |
|||
IdentityPasskeyData data, |
|||
Guid? tenantId) |
|||
{ |
|||
UserId = userId; |
|||
CredentialId = credentialId; |
|||
Data = data; |
|||
TenantId = tenantId; |
|||
} |
|||
|
|||
public override object[] GetKeys() |
|||
{ |
|||
return new object[] { UserId, CredentialId }; |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using Microsoft.AspNetCore.Identity; |
|||
|
|||
namespace Volo.Abp.Identity; |
|||
|
|||
public static class IdentityUserPasskeyExtensions |
|||
{ |
|||
public static void UpdateFromUserPasskeyInfo(this IdentityUserPasskey passkey, UserPasskeyInfo passkeyInfo) |
|||
{ |
|||
passkey.Data.Name = passkeyInfo.Name; |
|||
passkey.Data.SignCount = passkeyInfo.SignCount; |
|||
passkey.Data.IsBackedUp = passkeyInfo.IsBackedUp; |
|||
passkey.Data.IsUserVerified = passkeyInfo.IsUserVerified; |
|||
} |
|||
|
|||
public static UserPasskeyInfo ToUserPasskeyInfo(this IdentityUserPasskey passkey) |
|||
{ |
|||
return new UserPasskeyInfo( |
|||
passkey.CredentialId, |
|||
passkey.Data.PublicKey, |
|||
passkey.Data.CreatedAt, |
|||
passkey.Data.SignCount, |
|||
passkey.Data.Transports, |
|||
passkey.Data.IsUserVerified, |
|||
passkey.Data.IsBackupEligible, |
|||
passkey.Data.IsBackedUp, |
|||
passkey.Data.AttestationObject, |
|||
passkey.Data.ClientDataJson) |
|||
{ |
|||
Name = passkey.Data.Name |
|||
}; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue