Created
August 3, 2016 20:42
-
-
Save jakkaj/46ba343f3232289e754cc081ad57dd9e to your computer and use it in GitHub Desktop.
JWT Validation using ASP.NET Core build in stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//From <https://stormpath.com/blog/token-authentication-asp-net-core> | |
var tokenValidationParameters = new TokenValidationParameters | |
{ | |
// The signing key must match! | |
ValidateIssuerSigningKey = true, | |
IssuerSigningKey = signingKey, | |
// Validate the JWT Issuer (iss) claim | |
ValidateIssuer = true, | |
ValidIssuer = "ExampleIssuer", | |
// Validate the JWT Audience (aud) claim | |
ValidateAudience = true, | |
ValidAudience = "ExampleAudience", | |
// Validate the token expiry | |
ValidateLifetime = true, | |
// If you want to allow a certain amount of clock drift, set that here: | |
ClockSkew = TimeSpan.Zero | |
}; | |
app.UseJwtBearerAuthentication(new JwtBearerOptions | |
{ | |
AutomaticAuthenticate = true, | |
AutomaticChallenge = true, | |
TokenValidationParameters = tokenValidationParameters | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment