-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Setting DefaultScheme
in authentication configuration is not working
#46232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We removed support for setting the default scheme from configuration in preview7. See #42578. For .NET 7, the default scheme is inferred if there is only one scheme registered on the application. For other scenarios, we wanted to stick with the existing conventions for setting the default scheme. The fact that it exists in the sample is an artifact of it not being updated in reaction to the change. |
That's a pity. This one, along with being able to set builder.Services
.AddAuthentication()
.AddJwtBearer("FusionAuth")
.AddJwtBearer("UserJwts"); Instead of: builder.Services
.AddAuthentication(builder.Configuration.GetRequiredSection("Authentication")
.GetValue<string>("DefaultScheme")!)
.AddJwtBearer(
"FusionAuth",
options => options.TokenValidationParameters.NameClaimType = "preferred_username")
.AddJwtBearer("UserJwts"); |
var scheme = builder.Configuration["Authentication:DefaultScheme"] ?? throw new InvalidOperationException("Missing default scheme");
builder.Services
.AddAuthentication(scheme)
.AddJwtBearer(
"FusionAuth",
options => options.TokenValidationParameters.NameClaimType = "preferred_username")
.AddJwtBearer("UserJwts"); A little refactoring goes a long way in making the code look more readable. |
Sure. It's still not as clean though. 🙃 |
Another approach is to implement a |
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes. See our Issue Management Policies for more information. |
Uh oh!
There was an error while loading. Please reload this page.
Is there an existing issue for this?
Describe the bug
Setting
DefaultScheme
in authentication configuration does not appear to work.Expected Behavior
No response
Steps To Reproduce
MinimalJwtBearerSample.csproj
file (setTargetFramework
tonet7.0
, and add a package reference toMicrosoft.AspNetCore.Authentication.JwtBearer
version7.0.2
).http://localhost:5259/protected
.Exceptions (if any)
.NET Version
7.0.102
Anything else?
No response
The text was updated successfully, but these errors were encountered: