From 7e341a6b7c23cee7fdba8bb4499f0e5253841421 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Mon, 2 Jun 2025 15:44:12 +0200 Subject: [PATCH] Rename more instances to UserSignatureKeyPair --- .../Repositories/UserSignatureKeyPairRepository.cs | 6 +++--- .../Repositories/UserSigningKeysRepository.cs | 12 ++++++------ .../Models/UserSigningKeys.cs | 8 ++++---- .../Repositories/DatabaseContext.cs | 8 ++++---- .../2025-05-01_00_AddSigningKeysTable.sql | 14 +++++++------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Infrastructure.Dapper/KeyManagement/Repositories/UserSignatureKeyPairRepository.cs b/src/Infrastructure.Dapper/KeyManagement/Repositories/UserSignatureKeyPairRepository.cs index d90dcd56cf..e2c0349576 100644 --- a/src/Infrastructure.Dapper/KeyManagement/Repositories/UserSignatureKeyPairRepository.cs +++ b/src/Infrastructure.Dapper/KeyManagement/Repositories/UserSignatureKeyPairRepository.cs @@ -28,7 +28,7 @@ public class UserSignatureKeyPairRepository : Repository( - "[dbo].[UserSigningKey_ReadByUserId]", + "[dbo].[UserSignatureKeyPair_ReadByUserId]", new { UserId = userId @@ -42,7 +42,7 @@ public class UserSignatureKeyPairRepository : Repository { await connection.QueryAsync( - "[dbo].[UserSigningKey_SetForRotation]", + "[dbo].[UserSignatureKeyPair_SetForRotation]", new { Id = Guid.NewGuid(), @@ -63,7 +63,7 @@ public class UserSignatureKeyPairRepository : Repository { await connection.QueryAsync( - "[dbo].[UserSigningKey_UpdateForRotation]", + "[dbo].[UserSignatureKeyPair_UpdateForRotation]", new { UserId = grantorId, diff --git a/src/Infrastructure.EntityFramework/KeyManagement/Repositories/UserSigningKeysRepository.cs b/src/Infrastructure.EntityFramework/KeyManagement/Repositories/UserSigningKeysRepository.cs index e80216cf22..cd829a6da6 100644 --- a/src/Infrastructure.EntityFramework/KeyManagement/Repositories/UserSigningKeysRepository.cs +++ b/src/Infrastructure.EntityFramework/KeyManagement/Repositories/UserSigningKeysRepository.cs @@ -9,9 +9,9 @@ using Microsoft.Extensions.DependencyInjection; namespace Bit.Infrastructure.EntityFramework.KeyManagement.Repositories; -public class UserSignatureKeyPairRepository : Repository, IUserSignatureKeyPairRepository +public class UserSignatureKeyPairRepository : Repository, IUserSignatureKeyPairRepository { - public UserSignatureKeyPairRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper) : base(serviceScopeFactory, mapper, context => context.UserSigningKeys) + public UserSignatureKeyPairRepository(IServiceScopeFactory serviceScopeFactory, IMapper mapper) : base(serviceScopeFactory, mapper, context => context.UserSignatureKeyPair) { } @@ -19,7 +19,7 @@ public class UserSignatureKeyPairRepository : Repository x.UserId == grantorId); + var entity = await dbContext.UserSignatureKeyPair.FirstOrDefaultAsync(x => x.UserId == grantorId); if (entity != null) { entity.SignatureAlgorithm = signingKeys.SignatureAlgorithm; diff --git a/src/Infrastructure.EntityFramework/Models/UserSigningKeys.cs b/src/Infrastructure.EntityFramework/Models/UserSigningKeys.cs index 3cf66c1071..93ff4c54d8 100644 --- a/src/Infrastructure.EntityFramework/Models/UserSigningKeys.cs +++ b/src/Infrastructure.EntityFramework/Models/UserSigningKeys.cs @@ -2,15 +2,15 @@ namespace Bit.Infrastructure.EntityFramework.Models; -public class UserSigningKeys : Core.Entities.UserSignatureKeyPair +public class UserSignatureKeyPair : Core.Entities.UserSignatureKeyPair { public virtual User User { get; set; } } -public class UserSigningKeysMapperProfile : Profile +public class UserSignatureKeyPairMapperProfile : Profile { - public UserSigningKeysMapperProfile() + public UserSignatureKeyPairMapperProfile() { - CreateMap().ReverseMap(); + CreateMap().ReverseMap(); } } diff --git a/src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs b/src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs index 3a29e322e9..9954e98537 100644 --- a/src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs +++ b/src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs @@ -71,7 +71,7 @@ public class DatabaseContext : DbContext public DbSet TaxRates { get; set; } public DbSet Transactions { get; set; } public DbSet Users { get; set; } - public DbSet UserSigningKeys { get; set; } + public DbSet UserSignatureKeyPair { get; set; } public DbSet AuthRequests { get; set; } public DbSet OrganizationDomains { get; set; } public DbSet WebAuthnCredentials { get; set; } @@ -109,7 +109,7 @@ public class DatabaseContext : DbContext var eSsoConfig = builder.Entity(); var eTaxRate = builder.Entity(); var eUser = builder.Entity(); - var eUserSigningKeys = builder.Entity(); + var eUserSignatureKeyPair = builder.Entity(); var eOrganizationApiKey = builder.Entity(); var eOrganizationConnection = builder.Entity(); var eOrganizationDomain = builder.Entity(); @@ -130,7 +130,7 @@ public class DatabaseContext : DbContext eOrganizationConnection.Property(c => c.Id).ValueGeneratedNever(); eOrganizationDomain.Property(ar => ar.Id).ValueGeneratedNever(); aWebAuthnCredential.Property(ar => ar.Id).ValueGeneratedNever(); - eUserSigningKeys.Property(ar => ar.Id).ValueGeneratedNever(); + eUserSignatureKeyPair.Property(ar => ar.Id).ValueGeneratedNever(); eCollectionCipher.HasKey(cc => new { cc.CollectionId, cc.CipherId }); eCollectionUser.HasKey(cu => new { cu.CollectionId, cu.OrganizationUserId }); @@ -171,7 +171,7 @@ public class DatabaseContext : DbContext eOrganizationConnection.ToTable(nameof(OrganizationConnection)); eOrganizationDomain.ToTable(nameof(OrganizationDomain)); aWebAuthnCredential.ToTable(nameof(WebAuthnCredential)); - eUserSigningKeys.ToTable(nameof(UserSigningKeys)); + eUserSignatureKeyPair.ToTable(nameof(UserSignatureKeyPair)); ConfigureDateTimeUtcQueries(builder); } diff --git a/util/Migrator/DbScripts/2025-05-01_00_AddSigningKeysTable.sql b/util/Migrator/DbScripts/2025-05-01_00_AddSigningKeysTable.sql index 3eff0cc48c..e6ee6047a9 100644 --- a/util/Migrator/DbScripts/2025-05-01_00_AddSigningKeysTable.sql +++ b/util/Migrator/DbScripts/2025-05-01_00_AddSigningKeysTable.sql @@ -1,4 +1,4 @@ -CREATE TABLE [dbo].[UserSigningKey] ( +CREATE TABLE [dbo].[UserSignatureKeyPair] ( [Id] UNIQUEIDENTIFIER NOT NULL, [UserId] UNIQUEIDENTIFIER, [KeyType] TINYINT NOT NULL, @@ -11,17 +11,17 @@ CREATE TABLE [dbo].[UserSigningKey] ( ); GO -CREATE PROCEDURE [dbo].[UserSigningKey_ReadByUserId] +CREATE PROCEDURE [dbo].[UserSignatureKeyPair_ReadByUserId] @UserId UNIQUEIDENTIFIER AS BEGIN SELECT * - FROM [dbo].[UserSigningKey] + FROM [dbo].[UserSignatureKeyPair] WHERE [UserId] = @UserId; END GO -CREATE PROCEDURE [dbo].[UserSigningKey_UpdateForRotation] +CREATE PROCEDURE [dbo].[UserSignatureKeyPair_UpdateForRotation] @UserId UNIQUEIDENTIFIER, @KeyType TINYINT, @VerifyingKey VARCHAR(MAX), @@ -29,7 +29,7 @@ CREATE PROCEDURE [dbo].[UserSigningKey_UpdateForRotation] @RevisionDate DATETIME2(7) AS BEGIN - UPDATE [dbo].[UserSigningKey] + UPDATE [dbo].[UserSignatureKeyPair] SET [KeyType] = @KeyType, [VerifyingKey] = @VerifyingKey, [SigningKey] = @SigningKey, @@ -38,7 +38,7 @@ BEGIN END GO -CREATE PROCEDURE [dbo].[UserSigningKey_SetForRotation] +CREATE PROCEDURE [dbo].[UserSignatureKeyPair_SetForRotation] @Id UNIQUEIDENTIFIER, @UserId UNIQUEIDENTIFIER, @KeyType TINYINT, @@ -48,7 +48,7 @@ CREATE PROCEDURE [dbo].[UserSigningKey_SetForRotation] @RevisionDate DATETIME2(7) AS BEGIN - INSERT INTO [dbo].[UserSigningKey] ([Id], [UserId], [KeyType], [VerifyingKey], [SigningKey], [CreationDate], [RevisionDate]) + INSERT INTO [dbo].[UserSignatureKeyPair] ([Id], [UserId], [KeyType], [VerifyingKey], [SigningKey], [CreationDate], [RevisionDate]) VALUES (@Id, @UserId, @KeyType, @VerifyingKey, @SigningKey, @CreationDate, @RevisionDate) END GO