Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#region JwtTokenSection
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
services.AddAuthentication()
.AddJwtBearer(cfg =>
{
cfg.RequireHttpsMetadata = false;
cfg.SaveToken = true;
cfg.TokenValidationParameters = new TokenValidationParameters
{
ClockSkew = TimeSpan.FromMinutes(5),
RoleClaimType = "Roles",
RequireSignedTokens = true,
RequireExpirationTime = true,
ValidateLifetime = true,
ValidateAudience = true,
ValidIssuer = _config["Tokens:Issuer"],
ValidateIssuer = true,
ValidAudience = _config["Tokens:Issuer"],
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Tokens:Key"]))
};
});
services.ConfigureApplicationCookie(options => options.LoginPath = "/api/Token");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment