using System.Text; using Galaeth.Core.Configuration; using Microsoft.IdentityModel.Tokens; namespace Galaeth.ApiServer.Extensions; /// /// Extensions for . /// public static class JwtConfigurationExtensions { /// /// Generate an instance of from . /// /// Instance of . /// Instance of . public static TokenValidationParameters ToTokenValidationParameters(this JwtConfiguration config) { return new TokenValidationParameters() { ValidateIssuer = config.ValidateIssuer, ValidateAudience = config.ValidateAudience, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidAudience = config.Audience, ValidAudiences = [config.Audience], ValidIssuer = config.Issuer, IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(config.SecretKey)), }; } }