diff --git a/src/SimpleAuthentication/JwtBearer/JwtBearerService.cs b/src/SimpleAuthentication/JwtBearer/JwtBearerService.cs index 1ecc564..40e4bdb 100644 --- a/src/SimpleAuthentication/JwtBearer/JwtBearerService.cs +++ b/src/SimpleAuthentication/JwtBearer/JwtBearerService.cs @@ -12,7 +12,7 @@ internal class JwtBearerService(IOptions jwtBearerSettingsOpt public string CreateToken(string userName, IList? claims = null, string? issuer = null, string? audience = null, DateTime? absoluteExpiration = null) { - claims ??= new List(); + claims ??= []; claims.Update(jwtBearerSettings.NameClaimType, userName); claims.Update(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()); claims.Remove(JwtRegisteredClaimNames.Aud); @@ -37,6 +37,7 @@ public ClaimsPrincipal ValidateToken(string token, bool validateLifetime) { var tokenValidationParameters = new TokenValidationParameters { + AuthenticationType = jwtBearerSettings.SchemeName, NameClaimType = jwtBearerSettings.NameClaimType, RoleClaimType = jwtBearerSettings.RoleClaimType, ValidateIssuer = jwtBearerSettings.Issuers?.Any() ?? false, diff --git a/src/SimpleAuthentication/SimpleAuthenticationExtensions.cs b/src/SimpleAuthentication/SimpleAuthenticationExtensions.cs index a5723e8..af39e33 100644 --- a/src/SimpleAuthentication/SimpleAuthenticationExtensions.cs +++ b/src/SimpleAuthentication/SimpleAuthenticationExtensions.cs @@ -96,6 +96,7 @@ static void CheckAddJwtBearer(AuthenticationBuilder builder, IConfigurationSecti { options.TokenValidationParameters = new() { + AuthenticationType = settings.SchemeName, NameClaimType = settings.NameClaimType, RoleClaimType = settings.RoleClaimType, ValidateIssuer = settings.Issuers?.Any() ?? false,