dotnet / announcements

Subscribe to this repo to be notified of Announcements and changes in .NET Core.
Creative Commons Attribution 4.0 International
1.29k stars 44 forks source link

Changes in default authentication scheme handling for ASP.NET Core #231

Open captainsafia opened 2 years ago

captainsafia commented 2 years ago

Starting in .NET 7 Preview 7, we introduced new behavior in the authentication area in ASP.NET Core.

Previously, users were always required to set the default authentication scheme that would be used by authentication and authorization handlers, like so:

builder.Services.AddAuthentication("MyDefaultScheme");

Moving forward, when (and only when) a single authentication scheme is registered, that scheme will be treated as the default scheme. For example, "foobar" will be treated as the default scheme in the code below.

builder.Services.AddAuthentication().AddOAuth("foobar");

This change might expose unintended behavior changes in applications, such as authentication options being validated earlier than expected.

Discussion

This change can be discussed in https://github.com/dotnet/aspnetcore/issues/42828.