refactor(JwtSignatureService): verwendete primäre Struktur.
This commit is contained in:
parent
4142d2d948
commit
435c91955c
@ -5,21 +5,13 @@ using System.IdentityModel.Tokens.Jwt;
|
|||||||
|
|
||||||
namespace DigitalData.Core.Security
|
namespace DigitalData.Core.Security
|
||||||
{
|
{
|
||||||
public class JwtSignatureService<TPrincipal> : JwtSecurityTokenHandler
|
public class JwtSignatureService<TPrincipal>(IOptions<ClaimDescriptor<TPrincipal>> claimDescriptorOptions, TokenDescriptorProvider descriptorProvider) : JwtSecurityTokenHandler
|
||||||
{
|
{
|
||||||
private readonly ClaimDescriptor<TPrincipal> _claimDescriptor;
|
private readonly ClaimDescriptor<TPrincipal> _claimDescriptor = claimDescriptorOptions.Value;
|
||||||
|
|
||||||
private readonly TokenDescriptorProvider _descriptorProvider;
|
|
||||||
|
|
||||||
public JwtSignatureService(IOptions<ClaimDescriptor<TPrincipal>> claimDescriptorOptions, TokenDescriptorProvider descriptorProvider)
|
|
||||||
{
|
|
||||||
_claimDescriptor = claimDescriptorOptions.Value;
|
|
||||||
_descriptorProvider = descriptorProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SecurityToken CreateToken(TPrincipal subject, TokenDescription description)
|
public SecurityToken CreateToken(TPrincipal subject, TokenDescription description)
|
||||||
{
|
{
|
||||||
var descriptor = _descriptorProvider.Create(description: description);
|
var descriptor = descriptorProvider.Create(description: description);
|
||||||
descriptor.Claims = _claimDescriptor.CreateClaims?.Invoke(subject);
|
descriptor.Claims = _claimDescriptor.CreateClaims?.Invoke(subject);
|
||||||
descriptor.Subject = _claimDescriptor.CreateSubject?.Invoke(subject);
|
descriptor.Subject = _claimDescriptor.CreateSubject?.Invoke(subject);
|
||||||
return CreateToken(descriptor);
|
return CreateToken(descriptor);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user