- Notifications
You must be signed in to change notification settings - Fork3.6k
Add passkey support to Identity module.#24278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
maliming wants to merge3 commits intodevChoose a base branch fromPasskey
base:dev
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+457 −4
Open
Changes from1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
NextNext commit
Add passkey support to Identity module.
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commitf372e5dcebd18ba713e5909e24e32ef00d009ebc
There are no files selected for viewing
9 changes: 9 additions & 0 deletions...entity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/IdentityUserPasskeyConsts.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| namespaceVolo.Abp.Identity; | ||
| publicstaticclassIdentityUserPasskeyConsts | ||
| { | ||
| /// <summary> | ||
| /// Default value: 1024 | ||
| /// </summary> | ||
| publicstaticintMaxCredentialIdLength{get;set;}=1024; | ||
| } |
5 changes: 5 additions & 0 deletionsmodules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletionsmodules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityPasskeyData.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; } | ||
| } |
22 changes: 22 additions & 0 deletionsmodules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUser.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletionsmodules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserPasskey.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 }; | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions.../identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserPasskeyExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| }; | ||
| } | ||
| } |
105 changes: 105 additions & 0 deletionsmodules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserStore.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletions...EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions...workCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.