Dot Net Core JWT
Configuration for JWT auth
string domain = $"https://{ConfigurationManager.AppSettings["Auth0:Domain"]}/";
string customDomain = $"https://{ConfigurationManager.AppSettings["Auth0:CustomDomain"]}/";
string audience = ConfigurationManager.AppSettings["Auth0:Audience"];
OpenIdConnectSigningKeyResolver keyResolver = new OpenIdConnectSigningKeyResolver(domain);
app.UseJwtBearerAuthentication(
new JwtBearerAuthenticationOptions
{
AuthenticationMode = AuthenticationMode.Active,
TokenValidationParameters = new TokenValidationParameters
{
ValidAudience = audience,
ValidIssuers = new[] { domain, customDomain },
IssuerSigningKeyResolver = (token, securityToken, identifier, parameters) => keyResolver.GetSigningKey(identifier),
RoleClaimType = "https://my-custom-claim/role"
}
});