announcements icon indicating copy to clipboard operation
announcements copied to clipboard

Changes in default authentication scheme handling for ASP.NET Core

Open captainsafia opened this issue 3 years ago • 0 comments

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.

captainsafia avatar Jul 20 '22 00:07 captainsafia