Make a way to configure more options in TokenValidationParameters using simplified authentication configuration
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
I'm working on a project where I'm using JWT Bearer tokens with simplified auth configuration like this:
```csharp
builder.Services.AddAuthentication().AddJwtBearer();
```
My `appsettings.json` looks like this:
```json
{
"Authentication": {
"Schemes": {
"Bearer": {
"Authority": "...",
"MetadataAddress": "...",
"ValidIssuer": "...",
"ValidAudiences": [ "account" ]
}
}
}
}
```
My application uses an OIDC server that has a different `NameClaimType` than ASP.NET Security's default. It would be great to be able to specify that in the same configuration (along with `RoleClaimType` and maybe other options left behind). Something like this:
```json
{
"Authentication": {
"Schemes": {
"Bearer": {
"Authority": "...",
"MetadataAddress": "...",
"ValidIssuer": "...",
"ValidAudiences": [ "account" ],
"TokenValidationParameters": {
"NameClaimType": "name"
}
}
}
}
}
```
### Describe the solution you'd like
It would be straightforward to add a few more options in [JwtBearerConfigureOptions.cs](https://github.com/dotnet/aspnetcore/blob/c157c5c1962a66c4fe0212ed767f167bb9cdfb79/src/Security/Authentication/JwtBearer/src/JwtBearerConfigureOptions.cs#L64) to configure `TokenValidationParameters` further from configuration.
I could make a PR myself. Let me know what you think.
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.