1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-08 12:10:30 -05:00

Rename more instances to UserSignatureKeyPair

This commit is contained in:
Bernd Schoolmann 2025-06-02 15:44:12 +02:00
parent 2da5ff404d
commit 7e341a6b7c
No known key found for this signature in database
5 changed files with 24 additions and 24 deletions

View File

@ -28,7 +28,7 @@ public class UserSignatureKeyPairRepository : Repository<UserSignatureKeyPair, G
using (var connection = new SqlConnection(ConnectionString))
{
return await connection.QuerySingleOrDefaultAsync<SignatureKeyPairData>(
"[dbo].[UserSigningKey_ReadByUserId]",
"[dbo].[UserSignatureKeyPair_ReadByUserId]",
new
{
UserId = userId
@ -42,7 +42,7 @@ public class UserSignatureKeyPairRepository : Repository<UserSignatureKeyPair, G
return async (SqlConnection connection, SqlTransaction transaction) =>
{
await connection.QueryAsync(
"[dbo].[UserSigningKey_SetForRotation]",
"[dbo].[UserSignatureKeyPair_SetForRotation]",
new
{
Id = Guid.NewGuid(),
@ -63,7 +63,7 @@ public class UserSignatureKeyPairRepository : Repository<UserSignatureKeyPair, G
return async (SqlConnection connection, SqlTransaction transaction) =>
{
await connection.QueryAsync(
"[dbo].[UserSigningKey_UpdateForRotation]",
"[dbo].[UserSignatureKeyPair_UpdateForRotation]",
new
{
UserId = grantorId,

View File

@ -9,9 +9,9 @@ using Microsoft.Extensions.DependencyInjection;
namespace Bit.Infrastructure.EntityFramework.KeyManagement.Repositories;
public class UserSignatureKeyPairRepository : Repository<Core.Entities.UserSignatureKeyPair, Models.UserSigningKeys, Guid>, IUserSignatureKeyPairRepository
public class UserSignatureKeyPairRepository : Repository<Core.Entities.UserSignatureKeyPair, Models.UserSignatureKeyPair, Guid>, 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<Core.Entities.UserSigna
{
await using var scope = ServiceScopeFactory.CreateAsyncScope();
var dbContext = GetDatabaseContext(scope);
var signingKeys = await dbContext.UserSigningKeys.FindAsync(userId);
var signingKeys = await dbContext.UserSignatureKeyPair.FindAsync(userId);
if (signingKeys == null)
{
return null;
@ -39,7 +39,7 @@ public class UserSignatureKeyPairRepository : Repository<Core.Entities.UserSigna
{
await using var scope = ServiceScopeFactory.CreateAsyncScope();
var dbContext = GetDatabaseContext(scope);
var entity = new Models.UserSigningKeys
var entity = new Models.UserSignatureKeyPair
{
Id = Guid.NewGuid(),
UserId = userId,
@ -49,7 +49,7 @@ public class UserSignatureKeyPairRepository : Repository<Core.Entities.UserSigna
CreationDate = DateTime.UtcNow,
RevisionDate = DateTime.UtcNow,
};
await dbContext.UserSigningKeys.AddAsync(entity);
await dbContext.UserSignatureKeyPair.AddAsync(entity);
await dbContext.SaveChangesAsync();
};
}
@ -60,7 +60,7 @@ public class UserSignatureKeyPairRepository : Repository<Core.Entities.UserSigna
{
await using var scope = ServiceScopeFactory.CreateAsyncScope();
var dbContext = GetDatabaseContext(scope);
var entity = await dbContext.UserSigningKeys.FirstOrDefaultAsync(x => x.UserId == grantorId);
var entity = await dbContext.UserSignatureKeyPair.FirstOrDefaultAsync(x => x.UserId == grantorId);
if (entity != null)
{
entity.SignatureAlgorithm = signingKeys.SignatureAlgorithm;

View File

@ -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<Core.Entities.UserSignatureKeyPair, UserSigningKeys>().ReverseMap();
CreateMap<Core.Entities.UserSignatureKeyPair, UserSignatureKeyPair>().ReverseMap();
}
}

View File

@ -71,7 +71,7 @@ public class DatabaseContext : DbContext
public DbSet<TaxRate> TaxRates { get; set; }
public DbSet<Transaction> Transactions { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<UserSigningKeys> UserSigningKeys { get; set; }
public DbSet<UserSignatureKeyPair> UserSignatureKeyPair { get; set; }
public DbSet<AuthRequest> AuthRequests { get; set; }
public DbSet<OrganizationDomain> OrganizationDomains { get; set; }
public DbSet<WebAuthnCredential> WebAuthnCredentials { get; set; }
@ -109,7 +109,7 @@ public class DatabaseContext : DbContext
var eSsoConfig = builder.Entity<SsoConfig>();
var eTaxRate = builder.Entity<TaxRate>();
var eUser = builder.Entity<User>();
var eUserSigningKeys = builder.Entity<UserSigningKeys>();
var eUserSignatureKeyPair = builder.Entity<UserSignatureKeyPair>();
var eOrganizationApiKey = builder.Entity<OrganizationApiKey>();
var eOrganizationConnection = builder.Entity<OrganizationConnection>();
var eOrganizationDomain = builder.Entity<OrganizationDomain>();
@ -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);
}

View File

@ -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