Starting with NET 7, one can configure JWT validation values in appsettings.json
, e.g. as mentioned in this blog post (section Simplified configuration for the JwtBearer middleware):
"Authentication": {
"Schemes": {
"Bearer": {
"Authority": "https://{DOMAIN}",
"ValidAudiences": [ "{AUDIENCE}" ],
"ValidIssuer": "{DOMAIN}"
}
}
}
I however was unable to find official documentation for this on the Microsoft website. Anyone knows where to find the official documentation on this? How do I know which other properties I could configure here?
No they don't have an official documentation for this. Right now they are using internal JwtBearerConfigureOptions
to get section by schema name (in your case "Bearer") GitHub,and populate the JwtBearerOptions
based on nameof()
. They just added it to JwtBearerExtensions
in line 77.
PR when it was added. Issue create on github - still open. Sample on GitHub.
You can create a whole appsettings.json section based on their code but I wouldn't be much confident in implementing this right now.