feat(TokenDescriptorProvider): Erstellt, um eine beliebige TokenDescription auf SecurityTokenDescriptor abzubilden.

This commit is contained in:
Developer 02 2024-12-20 01:42:23 +01:00
parent 5469b20e4f
commit 2d675a16ad
2 changed files with 22 additions and 1 deletions

View File

@ -22,7 +22,9 @@ namespace DigitalData.Core.Security
return services;
_mappingProfile.Added = true;
return services.AddAutoMapper(typeof(MappingProfile).Assembly);
return services
.AddAutoMapper(typeof(MappingProfile).Assembly)
.AddSingleton<TokenDescriptorProvider>();
}
}

View File

@ -0,0 +1,19 @@
using AutoMapper;
using DigitalData.Core.Security.Config;
using Microsoft.IdentityModel.Tokens;
namespace DigitalData.Core.Security
{
public class TokenDescriptorProvider
{
private readonly IMapper _mapper;
public TokenDescriptorProvider(IMapper mapper)
{
_mapper = mapper;
}
public SecurityTokenDescriptor Create(TokenDescription description)
=> _mapper.Map(description, new SecurityTokenDescriptor());
}
}