refactor(IAsymCryptHandler): Umbenannt in ICryptograph
This commit is contained in:
parent
e8c98115b6
commit
d9d61368e3
@ -1,6 +1,6 @@
|
|||||||
namespace DigitalData.Core.Abstractions.Security
|
namespace DigitalData.Core.Abstractions.Security
|
||||||
{
|
{
|
||||||
public interface IAsymCryptHandler : IAsymmetricKeyFactory
|
public interface ICryptograph : IAsymmetricKeyFactory
|
||||||
{
|
{
|
||||||
IEnumerable<IAsymmetricPrivateKey> PrivateKeys { get; }
|
IEnumerable<IAsymmetricPrivateKey> PrivateKeys { get; }
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ using Microsoft.Extensions.Options;
|
|||||||
|
|
||||||
namespace DigitalData.Core.Security
|
namespace DigitalData.Core.Security
|
||||||
{
|
{
|
||||||
public class AsymCryptHandler : RSAFactory<AsymCryptParams>, IAsymCryptHandler, IAsymmetricKeyFactory
|
public class AsymCryptHandler : RSAFactory<AsymCryptParams>, ICryptograph, IAsymmetricKeyFactory
|
||||||
{
|
{
|
||||||
public IEnumerable<IAsymmetricPrivateKey> PrivateKeys { get; }
|
public IEnumerable<IAsymmetricPrivateKey> PrivateKeys { get; }
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ namespace DigitalData.Core.Security
|
|||||||
private static IServiceCollection AddAsymCryptHandler(this IServiceCollection services) => services
|
private static IServiceCollection AddAsymCryptHandler(this IServiceCollection services) => services
|
||||||
.AddParamsConfigureOptions<AsymCryptParams>()
|
.AddParamsConfigureOptions<AsymCryptParams>()
|
||||||
.AddAutoMapper(typeof(MappingProfile).Assembly)
|
.AddAutoMapper(typeof(MappingProfile).Assembly)
|
||||||
.AddSingleton<IAsymCryptHandler, AsymCryptHandler>();
|
.AddSingleton<ICryptograph, AsymCryptHandler>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers a custom asym crypt service with specified parameters from the given configuration section.
|
/// Registers a custom asym crypt service with specified parameters from the given configuration section.
|
||||||
|
|||||||
@ -15,14 +15,14 @@ namespace DigitalData.Core.Security
|
|||||||
|
|
||||||
private readonly TokenParams _params;
|
private readonly TokenParams _params;
|
||||||
|
|
||||||
private readonly IAsymCryptHandler _cryptHandler;
|
private readonly ICryptograph _cryptograph;
|
||||||
|
|
||||||
public JwtSignatureHandler(IOptions<ClaimDescriptor<TPrincipal>> claimDescriptorOptions, IMapper mapper, IOptions<TokenParams> tokenParamOptions, IAsymCryptHandler asymCryptHandler)
|
public JwtSignatureHandler(IOptions<ClaimDescriptor<TPrincipal>> claimDescriptorOptions, IMapper mapper, IOptions<TokenParams> tokenParamOptions, ICryptograph cryptograph)
|
||||||
{
|
{
|
||||||
_claimDescriptor = claimDescriptorOptions.Value;
|
_claimDescriptor = claimDescriptorOptions.Value;
|
||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
_params = tokenParamOptions.Value;
|
_params = tokenParamOptions.Value;
|
||||||
_cryptHandler = asymCryptHandler;
|
_cryptograph = cryptograph;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecurityToken CreateToken(TPrincipal subject, TokenDescription description)
|
public SecurityToken CreateToken(TPrincipal subject, TokenDescription description)
|
||||||
@ -38,7 +38,7 @@ namespace DigitalData.Core.Security
|
|||||||
var description = _params.Descriptions?.Get(issuer: issuer, audience: audience)
|
var description = _params.Descriptions?.Get(issuer: issuer, audience: audience)
|
||||||
?? throw new InvalidOperationException($"No or multiple token description found for issuer '{issuer}' and audience '{audience}'.");
|
?? throw new InvalidOperationException($"No or multiple token description found for issuer '{issuer}' and audience '{audience}'.");
|
||||||
|
|
||||||
description.SigningCredentials = _cryptHandler.PrivateKeys
|
description.SigningCredentials = _cryptograph.PrivateKeys
|
||||||
.Get(issuer: issuer, audience: audience)
|
.Get(issuer: issuer, audience: audience)
|
||||||
.CreateSigningCredentials(algorithm: description.SigningAlgorithm, digest: description.SigningDigest);
|
.CreateSigningCredentials(algorithm: description.SigningAlgorithm, digest: description.SigningDigest);
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ namespace DigitalData.Core.Security
|
|||||||
var description = _params.Descriptions.SingleOrDefault(description => description.ApiRoute == apiRoute)
|
var description = _params.Descriptions.SingleOrDefault(description => description.ApiRoute == apiRoute)
|
||||||
?? throw new InvalidOperationException($"No or multiple token description found for api route '{apiRoute}'.");
|
?? throw new InvalidOperationException($"No or multiple token description found for api route '{apiRoute}'.");
|
||||||
|
|
||||||
description.SigningCredentials = _cryptHandler.PrivateKeys
|
description.SigningCredentials = _cryptograph.PrivateKeys
|
||||||
.Get(issuer: description.Issuer, audience: description.Audience)
|
.Get(issuer: description.Issuer, audience: description.Audience)
|
||||||
.CreateSigningCredentials(algorithm: description.SigningAlgorithm, digest: description.SigningDigest);
|
.CreateSigningCredentials(algorithm: description.SigningAlgorithm, digest: description.SigningDigest);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user