Skip to content

Instantly share code, notes, and snippets.

@mehmetalierol
Created December 1, 2018 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehmetalierol/55410d2a51421160a341914e1b72cfa5 to your computer and use it in GitHub Desktop.
Save mehmetalierol/55410d2a51421160a341914e1b72cfa5 to your computer and use it in GitHub Desktop.
#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