Last active
April 7, 2019 12:23
-
-
Save ugurcemozturk/c92995de82c534c6a3207c4e13663b3d to your computer and use it in GitHub Desktop.
This file contains 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
namespace dotnetJWT.Configuration | |
{ | |
public static class JwtConfiguration | |
{ | |
public static void ConfigureJwt(IServiceCollection services) | |
{ | |
services.AddAuthentication(configureOptions => | |
{ | |
configureOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; | |
configureOptions.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; | |
}) | |
.AddJwtBearer(jwtOptions => | |
{ | |
jwtOptions.RequireHttpsMetadata = true; | |
jwtOptions.SaveToken = false; | |
jwtOptions.TokenValidationParameters = new TokenValidationParameters | |
{ | |
ValidateIssuerSigningKey = true, | |
IssuerSigningKey = new JsonWebKey("JWK_PUBLIC"), | |
ValidateIssuer = true, | |
ValidIssuer = "issuer", | |
ValidateAudience = true, | |
ValidAudience = "clientOrigin", | |
ValidateLifetime = true, | |
ValidateTokenReplay = true, | |
ClockSkew = TimeSpan.FromMinutes(1) | |
}; | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment