Skip to content

Instantly share code, notes, and snippets.

@chriskuech
Created April 1, 2020 20:01
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 chriskuech/b920f84b8f51cd346fdd7363aa68b9a3 to your computer and use it in GitHub Desktop.
Save chriskuech/b920f84b8f51cd346fdd7363aa68b9a3 to your computer and use it in GitHub Desktop.
public void ConfigureServices(IServiceCollection services)
{
var thisServiceUrl = "https://myotherservice.myorg.com"; // Read from appsettings instead.
... // configure services for your application
// configure services for authentication
services
.AddAuthentication(options =>
{
option.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
option.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.Audience = thisServiceUrl;
options.Authority = Constants.Issuer;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateAudience = true,
ValidateIssuer = true,
ValidateIssuerSigningKey = true,
ValidateLifetime = true,
};
});
return services;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment