fix(Kryptograph): Umbenannt in Krypto-Fabrik.

This commit is contained in:
Developer 02 2025-01-09 20:10:45 +01:00
parent d98b3f2867
commit 079f0c69c7
4 changed files with 9 additions and 9 deletions

View File

@ -1,6 +1,6 @@
namespace DigitalData.Core.Abstractions.Security
{
public interface ICryptograph : IAsymmetricKeyFactory
public interface ICryptoFactory : IAsymmetricKeyFactory
{
IEnumerable<IAsymmetricDecryptor> Decryptors { get; }

View File

@ -6,7 +6,7 @@ using Microsoft.Extensions.Options;
namespace DigitalData.Core.Security
{
public class Cryptograph : RSAFactory<CryptographParams>, ICryptograph, IAsymmetricKeyFactory
public class CryptoFactory : RSAFactory<CryptographParams>, ICryptoFactory, IAsymmetricKeyFactory
{
public IEnumerable<IAsymmetricDecryptor> Decryptors { get; }
@ -17,7 +17,7 @@ namespace DigitalData.Core.Security
public IEnumerable<IAsymmetricTokenDescriptor> TokenDescriptors { get; init; } = new List<IAsymmetricTokenDescriptor>();
public Cryptograph(IOptions<CryptographParams> options, ILogger<Cryptograph>? logger = null) : base(options)
public CryptoFactory(IOptions<CryptographParams> options, ILogger<CryptoFactory>? logger = null) : base(options)
{
logger?.LogInformation("Core.Secrets version: {Version}, Created on: {CreationDate}.", Secrets.Version, Secrets.CreationDate.ToString("dd.MM.yyyy"));

View File

@ -16,7 +16,7 @@ namespace DigitalData.Core.Security
private static IServiceCollection AddCryptograph(this IServiceCollection services) => services
.AddParamsConfigureOptions<CryptographParams>()
.AddAutoMapper(typeof(MappingProfile).Assembly)
.AddSingleton<ICryptograph, Cryptograph>();
.AddSingleton<ICryptoFactory, CryptoFactory>();
/// <summary>
/// Registers a custom asym crypt service with specified parameters from the given configuration section.

View File

@ -13,13 +13,13 @@ namespace DigitalData.Core.Security
private readonly IMapper _mapper;
private readonly ICryptograph _cryptograph;
private readonly ICryptoFactory _cryptoFactory;
public JwtSignatureHandler(IOptions<ClaimDescriptor<TPrincipal>> claimDescriptorOptions, IMapper mapper, ICryptograph cryptograph)
public JwtSignatureHandler(IOptions<ClaimDescriptor<TPrincipal>> claimDescriptorOptions, IMapper mapper, ICryptoFactory cryptoFactory)
{
_claimDescriptor = claimDescriptorOptions.Value;
_mapper = mapper;
_cryptograph = cryptograph;
_cryptoFactory = cryptoFactory;
}
public SecurityToken CreateToken(TPrincipal subject, IAsymmetricTokenDescriptor descriptor)
@ -32,14 +32,14 @@ namespace DigitalData.Core.Security
public SecurityToken CreateToken(TPrincipal subject, string issuer, string audience)
{
var descriptor = _cryptograph.TokenDescriptors.Get(issuer: issuer, audience: audience)
var descriptor = _cryptoFactory.TokenDescriptors.Get(issuer: issuer, audience: audience)
?? throw new InvalidOperationException($"No or multiple token description found for issuer '{issuer}' and audience '{audience}'.");
return CreateToken(subject: subject, descriptor: descriptor);
}
public SecurityToken CreateToken(TPrincipal subject, string apiRoute)
{
var desc = _cryptograph.TokenDescriptors.SingleOrDefault(desc => desc.ApiRoute == apiRoute)
var desc = _cryptoFactory.TokenDescriptors.SingleOrDefault(desc => desc.ApiRoute == apiRoute)
?? throw new InvalidOperationException($"No or multiple token description found for api route '{apiRoute}'.");
return CreateToken(subject: subject, descriptor: desc);