mirror of
https://github.com/bitwarden/server.git
synced 2025-06-08 20:20:32 -05:00
Rename more instances to UserSignatureKeyPair
This commit is contained in:
parent
2da5ff404d
commit
7e341a6b7c
@ -28,7 +28,7 @@ public class UserSignatureKeyPairRepository : Repository<UserSignatureKeyPair, G
|
|||||||
using (var connection = new SqlConnection(ConnectionString))
|
using (var connection = new SqlConnection(ConnectionString))
|
||||||
{
|
{
|
||||||
return await connection.QuerySingleOrDefaultAsync<SignatureKeyPairData>(
|
return await connection.QuerySingleOrDefaultAsync<SignatureKeyPairData>(
|
||||||
"[dbo].[UserSigningKey_ReadByUserId]",
|
"[dbo].[UserSignatureKeyPair_ReadByUserId]",
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
UserId = userId
|
UserId = userId
|
||||||
@ -42,7 +42,7 @@ public class UserSignatureKeyPairRepository : Repository<UserSignatureKeyPair, G
|
|||||||
return async (SqlConnection connection, SqlTransaction transaction) =>
|
return async (SqlConnection connection, SqlTransaction transaction) =>
|
||||||
{
|
{
|
||||||
await connection.QueryAsync(
|
await connection.QueryAsync(
|
||||||
"[dbo].[UserSigningKey_SetForRotation]",
|
"[dbo].[UserSignatureKeyPair_SetForRotation]",
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
@ -63,7 +63,7 @@ public class UserSignatureKeyPairRepository : Repository<UserSignatureKeyPair, G
|
|||||||
return async (SqlConnection connection, SqlTransaction transaction) =>
|
return async (SqlConnection connection, SqlTransaction transaction) =>
|
||||||
{
|
{
|
||||||
await connection.QueryAsync(
|
await connection.QueryAsync(
|
||||||
"[dbo].[UserSigningKey_UpdateForRotation]",
|
"[dbo].[UserSignatureKeyPair_UpdateForRotation]",
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
UserId = grantorId,
|
UserId = grantorId,
|
||||||
|
@ -9,9 +9,9 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
|
|
||||||
namespace Bit.Infrastructure.EntityFramework.KeyManagement.Repositories;
|
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();
|
await using var scope = ServiceScopeFactory.CreateAsyncScope();
|
||||||
var dbContext = GetDatabaseContext(scope);
|
var dbContext = GetDatabaseContext(scope);
|
||||||
var signingKeys = await dbContext.UserSigningKeys.FindAsync(userId);
|
var signingKeys = await dbContext.UserSignatureKeyPair.FindAsync(userId);
|
||||||
if (signingKeys == null)
|
if (signingKeys == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -39,7 +39,7 @@ public class UserSignatureKeyPairRepository : Repository<Core.Entities.UserSigna
|
|||||||
{
|
{
|
||||||
await using var scope = ServiceScopeFactory.CreateAsyncScope();
|
await using var scope = ServiceScopeFactory.CreateAsyncScope();
|
||||||
var dbContext = GetDatabaseContext(scope);
|
var dbContext = GetDatabaseContext(scope);
|
||||||
var entity = new Models.UserSigningKeys
|
var entity = new Models.UserSignatureKeyPair
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
UserId = userId,
|
UserId = userId,
|
||||||
@ -49,7 +49,7 @@ public class UserSignatureKeyPairRepository : Repository<Core.Entities.UserSigna
|
|||||||
CreationDate = DateTime.UtcNow,
|
CreationDate = DateTime.UtcNow,
|
||||||
RevisionDate = DateTime.UtcNow,
|
RevisionDate = DateTime.UtcNow,
|
||||||
};
|
};
|
||||||
await dbContext.UserSigningKeys.AddAsync(entity);
|
await dbContext.UserSignatureKeyPair.AddAsync(entity);
|
||||||
await dbContext.SaveChangesAsync();
|
await dbContext.SaveChangesAsync();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ public class UserSignatureKeyPairRepository : Repository<Core.Entities.UserSigna
|
|||||||
{
|
{
|
||||||
await using var scope = ServiceScopeFactory.CreateAsyncScope();
|
await using var scope = ServiceScopeFactory.CreateAsyncScope();
|
||||||
var dbContext = GetDatabaseContext(scope);
|
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)
|
if (entity != null)
|
||||||
{
|
{
|
||||||
entity.SignatureAlgorithm = signingKeys.SignatureAlgorithm;
|
entity.SignatureAlgorithm = signingKeys.SignatureAlgorithm;
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
namespace Bit.Infrastructure.EntityFramework.Models;
|
namespace Bit.Infrastructure.EntityFramework.Models;
|
||||||
|
|
||||||
public class UserSigningKeys : Core.Entities.UserSignatureKeyPair
|
public class UserSignatureKeyPair : Core.Entities.UserSignatureKeyPair
|
||||||
{
|
{
|
||||||
public virtual User User { get; set; }
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public class DatabaseContext : DbContext
|
|||||||
public DbSet<TaxRate> TaxRates { get; set; }
|
public DbSet<TaxRate> TaxRates { get; set; }
|
||||||
public DbSet<Transaction> Transactions { get; set; }
|
public DbSet<Transaction> Transactions { get; set; }
|
||||||
public DbSet<User> Users { 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<AuthRequest> AuthRequests { get; set; }
|
||||||
public DbSet<OrganizationDomain> OrganizationDomains { get; set; }
|
public DbSet<OrganizationDomain> OrganizationDomains { get; set; }
|
||||||
public DbSet<WebAuthnCredential> WebAuthnCredentials { get; set; }
|
public DbSet<WebAuthnCredential> WebAuthnCredentials { get; set; }
|
||||||
@ -109,7 +109,7 @@ public class DatabaseContext : DbContext
|
|||||||
var eSsoConfig = builder.Entity<SsoConfig>();
|
var eSsoConfig = builder.Entity<SsoConfig>();
|
||||||
var eTaxRate = builder.Entity<TaxRate>();
|
var eTaxRate = builder.Entity<TaxRate>();
|
||||||
var eUser = builder.Entity<User>();
|
var eUser = builder.Entity<User>();
|
||||||
var eUserSigningKeys = builder.Entity<UserSigningKeys>();
|
var eUserSignatureKeyPair = builder.Entity<UserSignatureKeyPair>();
|
||||||
var eOrganizationApiKey = builder.Entity<OrganizationApiKey>();
|
var eOrganizationApiKey = builder.Entity<OrganizationApiKey>();
|
||||||
var eOrganizationConnection = builder.Entity<OrganizationConnection>();
|
var eOrganizationConnection = builder.Entity<OrganizationConnection>();
|
||||||
var eOrganizationDomain = builder.Entity<OrganizationDomain>();
|
var eOrganizationDomain = builder.Entity<OrganizationDomain>();
|
||||||
@ -130,7 +130,7 @@ public class DatabaseContext : DbContext
|
|||||||
eOrganizationConnection.Property(c => c.Id).ValueGeneratedNever();
|
eOrganizationConnection.Property(c => c.Id).ValueGeneratedNever();
|
||||||
eOrganizationDomain.Property(ar => ar.Id).ValueGeneratedNever();
|
eOrganizationDomain.Property(ar => ar.Id).ValueGeneratedNever();
|
||||||
aWebAuthnCredential.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 });
|
eCollectionCipher.HasKey(cc => new { cc.CollectionId, cc.CipherId });
|
||||||
eCollectionUser.HasKey(cu => new { cu.CollectionId, cu.OrganizationUserId });
|
eCollectionUser.HasKey(cu => new { cu.CollectionId, cu.OrganizationUserId });
|
||||||
@ -171,7 +171,7 @@ public class DatabaseContext : DbContext
|
|||||||
eOrganizationConnection.ToTable(nameof(OrganizationConnection));
|
eOrganizationConnection.ToTable(nameof(OrganizationConnection));
|
||||||
eOrganizationDomain.ToTable(nameof(OrganizationDomain));
|
eOrganizationDomain.ToTable(nameof(OrganizationDomain));
|
||||||
aWebAuthnCredential.ToTable(nameof(WebAuthnCredential));
|
aWebAuthnCredential.ToTable(nameof(WebAuthnCredential));
|
||||||
eUserSigningKeys.ToTable(nameof(UserSigningKeys));
|
eUserSignatureKeyPair.ToTable(nameof(UserSignatureKeyPair));
|
||||||
|
|
||||||
ConfigureDateTimeUtcQueries(builder);
|
ConfigureDateTimeUtcQueries(builder);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
CREATE TABLE [dbo].[UserSigningKey] (
|
CREATE TABLE [dbo].[UserSignatureKeyPair] (
|
||||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||||
[UserId] UNIQUEIDENTIFIER,
|
[UserId] UNIQUEIDENTIFIER,
|
||||||
[KeyType] TINYINT NOT NULL,
|
[KeyType] TINYINT NOT NULL,
|
||||||
@ -11,17 +11,17 @@ CREATE TABLE [dbo].[UserSigningKey] (
|
|||||||
);
|
);
|
||||||
GO
|
GO
|
||||||
|
|
||||||
CREATE PROCEDURE [dbo].[UserSigningKey_ReadByUserId]
|
CREATE PROCEDURE [dbo].[UserSignatureKeyPair_ReadByUserId]
|
||||||
@UserId UNIQUEIDENTIFIER
|
@UserId UNIQUEIDENTIFIER
|
||||||
AS
|
AS
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM [dbo].[UserSigningKey]
|
FROM [dbo].[UserSignatureKeyPair]
|
||||||
WHERE [UserId] = @UserId;
|
WHERE [UserId] = @UserId;
|
||||||
END
|
END
|
||||||
GO
|
GO
|
||||||
|
|
||||||
CREATE PROCEDURE [dbo].[UserSigningKey_UpdateForRotation]
|
CREATE PROCEDURE [dbo].[UserSignatureKeyPair_UpdateForRotation]
|
||||||
@UserId UNIQUEIDENTIFIER,
|
@UserId UNIQUEIDENTIFIER,
|
||||||
@KeyType TINYINT,
|
@KeyType TINYINT,
|
||||||
@VerifyingKey VARCHAR(MAX),
|
@VerifyingKey VARCHAR(MAX),
|
||||||
@ -29,7 +29,7 @@ CREATE PROCEDURE [dbo].[UserSigningKey_UpdateForRotation]
|
|||||||
@RevisionDate DATETIME2(7)
|
@RevisionDate DATETIME2(7)
|
||||||
AS
|
AS
|
||||||
BEGIN
|
BEGIN
|
||||||
UPDATE [dbo].[UserSigningKey]
|
UPDATE [dbo].[UserSignatureKeyPair]
|
||||||
SET [KeyType] = @KeyType,
|
SET [KeyType] = @KeyType,
|
||||||
[VerifyingKey] = @VerifyingKey,
|
[VerifyingKey] = @VerifyingKey,
|
||||||
[SigningKey] = @SigningKey,
|
[SigningKey] = @SigningKey,
|
||||||
@ -38,7 +38,7 @@ BEGIN
|
|||||||
END
|
END
|
||||||
GO
|
GO
|
||||||
|
|
||||||
CREATE PROCEDURE [dbo].[UserSigningKey_SetForRotation]
|
CREATE PROCEDURE [dbo].[UserSignatureKeyPair_SetForRotation]
|
||||||
@Id UNIQUEIDENTIFIER,
|
@Id UNIQUEIDENTIFIER,
|
||||||
@UserId UNIQUEIDENTIFIER,
|
@UserId UNIQUEIDENTIFIER,
|
||||||
@KeyType TINYINT,
|
@KeyType TINYINT,
|
||||||
@ -48,7 +48,7 @@ CREATE PROCEDURE [dbo].[UserSigningKey_SetForRotation]
|
|||||||
@RevisionDate DATETIME2(7)
|
@RevisionDate DATETIME2(7)
|
||||||
AS
|
AS
|
||||||
BEGIN
|
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)
|
VALUES (@Id, @UserId, @KeyType, @VerifyingKey, @SigningKey, @CreationDate, @RevisionDate)
|
||||||
END
|
END
|
||||||
GO
|
GO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user