diff --git a/AspNetCoreIdentityFido2Mfa/Data/ApplicationDbContext.cs b/AspNetCoreIdentityFido2Mfa/Data/ApplicationDbContext.cs index f0138a6..9f78308 100644 --- a/AspNetCoreIdentityFido2Mfa/Data/ApplicationDbContext.cs +++ b/AspNetCoreIdentityFido2Mfa/Data/ApplicationDbContext.cs @@ -11,11 +11,11 @@ public ApplicationDbContext(DbContextOptions options) { } - public DbSet FidoStoredCredential => Set(); + public DbSet FidoCredentials => Set(); protected override void OnModelCreating(ModelBuilder builder) { - builder.Entity().HasKey(m => m.Id); + builder.Entity().HasKey(m => m.Id); base.OnModelCreating(builder); } diff --git a/AspNetCoreIdentityFido2Mfa/Fido2/Fido2Store.cs b/AspNetCoreIdentityFido2Mfa/Fido2/Fido2Store.cs index e0e5710..7bfa8ff 100644 --- a/AspNetCoreIdentityFido2Mfa/Fido2/Fido2Store.cs +++ b/AspNetCoreIdentityFido2Mfa/Fido2/Fido2Store.cs @@ -14,42 +14,42 @@ public Fido2Store(ApplicationDbContext applicationDbContext) _applicationDbContext = applicationDbContext; } - public async Task> GetCredentialsByUserNameAsync(string? username) + public async Task> GetCredentialsByUserNameAsync(string? username) { - return await _applicationDbContext.FidoStoredCredential.Where(c => c.UserName == username).ToListAsync(); + return await _applicationDbContext.FidoCredentials.Where(c => c.UserName == username).ToListAsync(); } public async Task RemoveCredentialsByUserNameAsync(string username) { - var items = await _applicationDbContext.FidoStoredCredential.Where(c => c.UserName == username).ToListAsync(); + var items = await _applicationDbContext.FidoCredentials.Where(c => c.UserName == username).ToListAsync(); if (items != null) { foreach (var fido2Key in items) { - _applicationDbContext.FidoStoredCredential.Remove(fido2Key); + _applicationDbContext.FidoCredentials.Remove(fido2Key); }; await _applicationDbContext.SaveChangesAsync(); } } - public async Task GetCredentialByIdAsync(byte[] id) + public async Task GetCredentialByIdAsync(byte[] id) { var credentialIdString = Base64Url.Encode(id); //byte[] credentialIdStringByte = Base64Url.Decode(credentialIdString); - var cred = await _applicationDbContext.FidoStoredCredential + var cred = await _applicationDbContext.FidoCredentials .Where(c => c.DescriptorJson != null && c.DescriptorJson.Contains(credentialIdString)) .FirstOrDefaultAsync(); return cred; } - public Task> GetCredentialsByUserHandleAsync(byte[] userHandle) + public Task> GetCredentialsByUserHandleAsync(byte[] userHandle) { - return Task.FromResult>( + return Task.FromResult>( _applicationDbContext - .FidoStoredCredential.Where(c => c.UserHandle != null && c.UserHandle.SequenceEqual(userHandle)) + .FidoCredentials.Where(c => c.UserHandle != null && c.UserHandle.SequenceEqual(userHandle)) .ToList()); } @@ -58,7 +58,7 @@ public async Task UpdateCounterAsync(byte[] credentialId, uint counter) var credentialIdString = Base64Url.Encode(credentialId); //byte[] credentialIdStringByte = Base64Url.Decode(credentialIdString); - var cred = await _applicationDbContext.FidoStoredCredential + var cred = await _applicationDbContext.FidoCredentials .Where(c => c.DescriptorJson != null && c.DescriptorJson.Contains(credentialIdString)).FirstOrDefaultAsync(); if(cred != null) @@ -68,10 +68,10 @@ public async Task UpdateCounterAsync(byte[] credentialId, uint counter) } } - public async Task AddCredentialToUserAsync(Fido2User user, FidoStoredCredential credential) + public async Task AddCredentialToUserAsync(Fido2User user, FidoCredential credential) { credential.UserId = user.Id; - _applicationDbContext.FidoStoredCredential.Add(credential); + _applicationDbContext.FidoCredentials.Add(credential); await _applicationDbContext.SaveChangesAsync(); } @@ -80,7 +80,7 @@ public async Task> GetUsersByCredentialIdAsync(byte[] cre var credentialIdString = Base64Url.Encode(credentialId); //byte[] credentialIdStringByte = Base64Url.Decode(credentialIdString); - var cred = await _applicationDbContext.FidoStoredCredential + var cred = await _applicationDbContext.FidoCredentials .Where(c => c.DescriptorJson != null && c.DescriptorJson.Contains(credentialIdString)).FirstOrDefaultAsync(); if (cred == null || cred.UserId == null) diff --git a/AspNetCoreIdentityFido2Mfa/Fido2/FidoStoredCredential.cs b/AspNetCoreIdentityFido2Mfa/Fido2/FidoStoredCredential.cs index d063264..b7d4747 100644 --- a/AspNetCoreIdentityFido2Mfa/Fido2/FidoStoredCredential.cs +++ b/AspNetCoreIdentityFido2Mfa/Fido2/FidoStoredCredential.cs @@ -7,7 +7,7 @@ namespace Fido2Identity; /// /// Represents a WebAuthn credential. /// -public class FidoStoredCredential +public class FidoCredential { /// /// Gets or sets the primary key for this user. diff --git a/AspNetCoreIdentityFido2Mfa/Fido2/MfaFido2RegisterController.cs b/AspNetCoreIdentityFido2Mfa/Fido2/MfaFido2RegisterController.cs index 2dea7ad..883a39e 100644 --- a/AspNetCoreIdentityFido2Mfa/Fido2/MfaFido2RegisterController.cs +++ b/AspNetCoreIdentityFido2Mfa/Fido2/MfaFido2RegisterController.cs @@ -129,7 +129,7 @@ async Task callback(IsCredentialIdUniqueToUserParams args, CancellationTok if(success.Result != null) { // 3. Store the credentials in db - await _fido2Store.AddCredentialToUserAsync(options.User, new FidoStoredCredential + await _fido2Store.AddCredentialToUserAsync(options.User, new FidoCredential { UserName = options.User.Name, Descriptor = new PublicKeyCredentialDescriptor(success.Result.CredentialId), diff --git a/AspNetCoreIdentityFido2Mfa/Fido2/PwFido2RegisterController.cs b/AspNetCoreIdentityFido2Mfa/Fido2/PwFido2RegisterController.cs index 316b9c6..4eefe1a 100644 --- a/AspNetCoreIdentityFido2Mfa/Fido2/PwFido2RegisterController.cs +++ b/AspNetCoreIdentityFido2Mfa/Fido2/PwFido2RegisterController.cs @@ -132,7 +132,7 @@ public async Task MakeCredential([FromBody] AuthenticatorAttestation if (success.Result != null) { // 3. Store the credentials in db - await _fido2Store.AddCredentialToUserAsync(options.User, new FidoStoredCredential + await _fido2Store.AddCredentialToUserAsync(options.User, new FidoCredential { UserName = options.User.Name, Descriptor = new PublicKeyCredentialDescriptor(success.Result.CredentialId), diff --git a/AspNetCoreIdentityFido2Mfa/Migrations/20210820152613_init_identity.Designer.cs b/AspNetCoreIdentityFido2Mfa/Migrations/20210820152613_init_identity.Designer.cs index a9e1c28..0d1c2bf 100644 --- a/AspNetCoreIdentityFido2Mfa/Migrations/20210820152613_init_identity.Designer.cs +++ b/AspNetCoreIdentityFido2Mfa/Migrations/20210820152613_init_identity.Designer.cs @@ -21,7 +21,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasAnnotation("ProductVersion", "5.0.9") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("Fido2Identity.FidoStoredCredential", b => + modelBuilder.Entity("Fido2Identity.FidoCredentials", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -57,7 +57,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("FidoStoredCredential"); + b.ToTable("FidoCredentials"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => diff --git a/AspNetCoreIdentityFido2Mfa/Migrations/20210820152613_init_identity.cs b/AspNetCoreIdentityFido2Mfa/Migrations/20210820152613_init_identity.cs index 0f92e77..6a24fd5 100644 --- a/AspNetCoreIdentityFido2Mfa/Migrations/20210820152613_init_identity.cs +++ b/AspNetCoreIdentityFido2Mfa/Migrations/20210820152613_init_identity.cs @@ -47,7 +47,7 @@ protected override void Up(MigrationBuilder migrationBuilder) }); migrationBuilder.CreateTable( - name: "FidoStoredCredential", + name: "FidoCredential", columns: table => new { Id = table.Column(type: "int", nullable: false) @@ -64,7 +64,7 @@ protected override void Up(MigrationBuilder migrationBuilder) }, constraints: table => { - table.PrimaryKey("PK_FidoStoredCredential", x => x.Id); + table.PrimaryKey("PK_FidoCredential", x => x.Id); }); migrationBuilder.CreateTable( @@ -231,7 +231,7 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "AspNetUserTokens"); migrationBuilder.DropTable( - name: "FidoStoredCredential"); + name: "FidoCredentials"); migrationBuilder.DropTable( name: "AspNetRoles"); diff --git a/AspNetCoreIdentityFido2Mfa/Migrations/ApplicationDbContextModelSnapshot.cs b/AspNetCoreIdentityFido2Mfa/Migrations/ApplicationDbContextModelSnapshot.cs index 4b02915..b6d4c04 100644 --- a/AspNetCoreIdentityFido2Mfa/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/AspNetCoreIdentityFido2Mfa/Migrations/ApplicationDbContextModelSnapshot.cs @@ -19,7 +19,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasAnnotation("ProductVersion", "5.0.9") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("Fido2Identity.FidoStoredCredential", b => + modelBuilder.Entity("Fido2Identity.FidoCredentials", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -55,7 +55,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("FidoStoredCredential"); + b.ToTable("FidoCredentials"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => diff --git a/AspNetCoreIdentityFido2Passwordless/Data/ApplicationDbContext.cs b/AspNetCoreIdentityFido2Passwordless/Data/ApplicationDbContext.cs index 079c98e..a86283e 100644 --- a/AspNetCoreIdentityFido2Passwordless/Data/ApplicationDbContext.cs +++ b/AspNetCoreIdentityFido2Passwordless/Data/ApplicationDbContext.cs @@ -11,11 +11,11 @@ public ApplicationDbContext(DbContextOptions options) { } - public DbSet FidoStoredCredential => Set(); + public DbSet FidoCredentials => Set(); protected override void OnModelCreating(ModelBuilder builder) { - builder.Entity().HasKey(m => m.Id); + builder.Entity().HasKey(m => m.Id); base.OnModelCreating(builder); } diff --git a/AspNetCoreIdentityFido2Passwordless/Fido2/Fido2Store.cs b/AspNetCoreIdentityFido2Passwordless/Fido2/Fido2Store.cs index 34b888a..c4639d0 100644 --- a/AspNetCoreIdentityFido2Passwordless/Fido2/Fido2Store.cs +++ b/AspNetCoreIdentityFido2Passwordless/Fido2/Fido2Store.cs @@ -14,42 +14,42 @@ public Fido2Store(ApplicationDbContext applicationDbContext) _applicationDbContext = applicationDbContext; } - public async Task> GetCredentialsByUserNameAsync(string? username) + public async Task> GetCredentialsByUserNameAsync(string? username) { - return await _applicationDbContext.FidoStoredCredential.Where(c => c.UserName == username).ToListAsync(); + return await _applicationDbContext.FidoCredentials.Where(c => c.UserName == username).ToListAsync(); } public async Task RemoveCredentialsByUserNameAsync(string username) { - var items = await _applicationDbContext.FidoStoredCredential.Where(c => c.UserName == username).ToListAsync(); + var items = await _applicationDbContext.FidoCredentials.Where(c => c.UserName == username).ToListAsync(); if (items != null) { foreach (var fido2Key in items) { - _applicationDbContext.FidoStoredCredential.Remove(fido2Key); + _applicationDbContext.FidoCredentials.Remove(fido2Key); }; await _applicationDbContext.SaveChangesAsync(); } } - public async Task GetCredentialByIdAsync(byte[] id) + public async Task GetCredentialByIdAsync(byte[] id) { var credentialIdString = Base64Url.Encode(id); //byte[] credentialIdStringByte = Base64Url.Decode(credentialIdString); - var cred = await _applicationDbContext.FidoStoredCredential + var cred = await _applicationDbContext.FidoCredentials .Where(c => c.DescriptorJson != null && c.DescriptorJson.Contains(credentialIdString)) .FirstOrDefaultAsync(); return cred; } - public Task> GetCredentialsByUserHandleAsync(byte[] userHandle) + public Task> GetCredentialsByUserHandleAsync(byte[] userHandle) { - return Task.FromResult>( + return Task.FromResult>( _applicationDbContext - .FidoStoredCredential.Where(c => c.UserHandle != null && c.UserHandle.SequenceEqual(userHandle)) + .FidoCredentials.Where(c => c.UserHandle != null && c.UserHandle.SequenceEqual(userHandle)) .ToList()); } @@ -58,7 +58,7 @@ public async Task UpdateCounterAsync(byte[] credentialId, uint counter) var credentialIdString = Base64Url.Encode(credentialId); //byte[] credentialIdStringByte = Base64Url.Decode(credentialIdString); - var cred = await _applicationDbContext.FidoStoredCredential + var cred = await _applicationDbContext.FidoCredentials .Where(c => c.DescriptorJson != null && c.DescriptorJson.Contains(credentialIdString)).FirstOrDefaultAsync(); if(cred != null) @@ -68,10 +68,10 @@ public async Task UpdateCounterAsync(byte[] credentialId, uint counter) } } - public async Task AddCredentialToUserAsync(Fido2User user, FidoStoredCredential credential) + public async Task AddCredentialToUserAsync(Fido2User user, FidoCredential credential) { credential.UserId = user.Id; - _applicationDbContext.FidoStoredCredential.Add(credential); + _applicationDbContext.FidoCredentials.Add(credential); await _applicationDbContext.SaveChangesAsync(); } @@ -80,7 +80,7 @@ public async Task> GetUsersByCredentialIdAsync(byte[] cre var credentialIdString = Base64Url.Encode(credentialId); //byte[] credentialIdStringByte = Base64Url.Decode(credentialIdString); - var cred = await _applicationDbContext.FidoStoredCredential + var cred = await _applicationDbContext.FidoCredentials .Where(c => c.DescriptorJson != null && c.DescriptorJson.Contains(credentialIdString)).FirstOrDefaultAsync(); if (cred == null || cred.UserId == null) diff --git a/AspNetCoreIdentityFido2Passwordless/Fido2/FidoStoredCredential.cs b/AspNetCoreIdentityFido2Passwordless/Fido2/FidoStoredCredential.cs index d063264..b7d4747 100644 --- a/AspNetCoreIdentityFido2Passwordless/Fido2/FidoStoredCredential.cs +++ b/AspNetCoreIdentityFido2Passwordless/Fido2/FidoStoredCredential.cs @@ -7,7 +7,7 @@ namespace Fido2Identity; /// /// Represents a WebAuthn credential. /// -public class FidoStoredCredential +public class FidoCredential { /// /// Gets or sets the primary key for this user. diff --git a/AspNetCoreIdentityFido2Passwordless/Fido2/MfaFido2RegisterController.cs b/AspNetCoreIdentityFido2Passwordless/Fido2/MfaFido2RegisterController.cs index 2dea7ad..883a39e 100644 --- a/AspNetCoreIdentityFido2Passwordless/Fido2/MfaFido2RegisterController.cs +++ b/AspNetCoreIdentityFido2Passwordless/Fido2/MfaFido2RegisterController.cs @@ -129,7 +129,7 @@ async Task callback(IsCredentialIdUniqueToUserParams args, CancellationTok if(success.Result != null) { // 3. Store the credentials in db - await _fido2Store.AddCredentialToUserAsync(options.User, new FidoStoredCredential + await _fido2Store.AddCredentialToUserAsync(options.User, new FidoCredential { UserName = options.User.Name, Descriptor = new PublicKeyCredentialDescriptor(success.Result.CredentialId), diff --git a/AspNetCoreIdentityFido2Passwordless/Fido2/PwFido2RegisterController.cs b/AspNetCoreIdentityFido2Passwordless/Fido2/PwFido2RegisterController.cs index 316b9c6..4eefe1a 100644 --- a/AspNetCoreIdentityFido2Passwordless/Fido2/PwFido2RegisterController.cs +++ b/AspNetCoreIdentityFido2Passwordless/Fido2/PwFido2RegisterController.cs @@ -132,7 +132,7 @@ public async Task MakeCredential([FromBody] AuthenticatorAttestation if (success.Result != null) { // 3. Store the credentials in db - await _fido2Store.AddCredentialToUserAsync(options.User, new FidoStoredCredential + await _fido2Store.AddCredentialToUserAsync(options.User, new FidoCredential { UserName = options.User.Name, Descriptor = new PublicKeyCredentialDescriptor(success.Result.CredentialId), diff --git a/AspNetCoreIdentityFido2Passwordless/Migrations/20200506090154_init.Designer.cs b/AspNetCoreIdentityFido2Passwordless/Migrations/20200506090154_init.Designer.cs index d561e6d..f13002d 100644 --- a/AspNetCoreIdentityFido2Passwordless/Migrations/20200506090154_init.Designer.cs +++ b/AspNetCoreIdentityFido2Passwordless/Migrations/20200506090154_init.Designer.cs @@ -21,7 +21,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("Fido2Identity.FidoStoredCredential", b => + modelBuilder.Entity("Fido2Identity.FidoCredentials", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -57,7 +57,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("FidoStoredCredential"); + b.ToTable("FidoCredentials"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => diff --git a/AspNetCoreIdentityFido2Passwordless/Migrations/20200506090154_init.cs b/AspNetCoreIdentityFido2Passwordless/Migrations/20200506090154_init.cs index 9c5836f..368f403 100644 --- a/AspNetCoreIdentityFido2Passwordless/Migrations/20200506090154_init.cs +++ b/AspNetCoreIdentityFido2Passwordless/Migrations/20200506090154_init.cs @@ -47,7 +47,7 @@ protected override void Up(MigrationBuilder migrationBuilder) }); migrationBuilder.CreateTable( - name: "FidoStoredCredential", + name: "FidoCredential", columns: table => new { Id = table.Column(nullable: false) @@ -64,7 +64,7 @@ protected override void Up(MigrationBuilder migrationBuilder) }, constraints: table => { - table.PrimaryKey("PK_FidoStoredCredential", x => x.Id); + table.PrimaryKey("PK_FidoCredential", x => x.Id); }); migrationBuilder.CreateTable( @@ -231,7 +231,7 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "AspNetUserTokens"); migrationBuilder.DropTable( - name: "FidoStoredCredential"); + name: "FidoCredentials"); migrationBuilder.DropTable( name: "AspNetRoles"); diff --git a/AspNetCoreIdentityFido2Passwordless/Migrations/ApplicationDbContextModelSnapshot.cs b/AspNetCoreIdentityFido2Passwordless/Migrations/ApplicationDbContextModelSnapshot.cs index ac26d71..018b582 100644 --- a/AspNetCoreIdentityFido2Passwordless/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/AspNetCoreIdentityFido2Passwordless/Migrations/ApplicationDbContextModelSnapshot.cs @@ -19,7 +19,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - modelBuilder.Entity("Fido2Identity.FidoStoredCredential", b => + modelBuilder.Entity("Fido2Identity.FidoCredentials", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -55,7 +55,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("FidoStoredCredential"); + b.ToTable("FidoCredentials"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>