diff --git a/DigitalData.Core.Security/JwtSignatureHandler.cs b/DigitalData.Core.Security/JwtSignatureHandler.cs index 0f71e3e..8da999d 100644 --- a/DigitalData.Core.Security/JwtSignatureHandler.cs +++ b/DigitalData.Core.Security/JwtSignatureHandler.cs @@ -13,15 +13,15 @@ namespace DigitalData.Core.Security private readonly IMapper _mapper; - private readonly TokenParams? _params; + private readonly TokenParams _params; private readonly IAsymCryptHandler _cryptHandler; - public JwtSignatureHandler(IOptions> claimDescriptorOptions, IMapper mapper, IOptions? tokenParamOptions, IAsymCryptHandler asymCryptHandler) + public JwtSignatureHandler(IOptions> claimDescriptorOptions, IMapper mapper, IOptions tokenParamOptions, IAsymCryptHandler asymCryptHandler) { _claimDescriptor = claimDescriptorOptions.Value; _mapper = mapper; - _params = tokenParamOptions?.Value; + _params = tokenParamOptions.Value; _cryptHandler = asymCryptHandler; } @@ -35,7 +35,7 @@ namespace DigitalData.Core.Security public SecurityToken CreateToken(TPrincipal subject, string issuer, string audience) { - var description = _tokenDescriptions?.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}'."); description.SigningCredentials = _cryptHandler.Decryptors @@ -47,7 +47,7 @@ namespace DigitalData.Core.Security public SecurityToken CreateToken(TPrincipal subject, string apiRoute) { - 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}'."); description.SigningCredentials = _cryptHandler.Decryptors