fix: TokenParams-Kaliber erstellt, um Token-Beschreibungen über IOptions zu konfigurieren

This commit is contained in:
Developer 02
2025-01-07 10:21:25 +01:00
parent 15e909064f
commit 4874079b69
3 changed files with 21 additions and 17 deletions

View File

@@ -13,15 +13,15 @@ namespace DigitalData.Core.Security
private readonly IMapper _mapper;
private readonly IEnumerable<TokenDescription>? _tokenDescriptions;
private readonly TokenParams? _params;
private readonly IAsymCryptHandler _cryptHandler;
public JwtSignatureHandler(IOptions<ClaimDescriptor<TPrincipal>> claimDescriptorOptions, IMapper mapper, IOptions<IEnumerable<TokenDescription>>? tokenDescriptionOptions, IAsymCryptHandler asymCryptHandler)
public JwtSignatureHandler(IOptions<ClaimDescriptor<TPrincipal>> claimDescriptorOptions, IMapper mapper, IOptions<TokenParams>? tokenParamOptions, IAsymCryptHandler asymCryptHandler)
{
_claimDescriptor = claimDescriptorOptions.Value;
_mapper = mapper;
_tokenDescriptions = tokenDescriptionOptions?.Value;
_params = tokenParamOptions?.Value;
_cryptHandler = asymCryptHandler;
}
@@ -47,7 +47,7 @@ namespace DigitalData.Core.Security
public SecurityToken CreateToken(TPrincipal subject, string apiRoute)
{
var description = _tokenDescriptions?.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}'.");
description.SigningCredentials = _cryptHandler.Decryptors