According to this article :
In 1.x, the AutomaticAuthenticate and AutomaticChallenge properties had to be set on a single authentication scheme. There was no good way to secure this.
In 2.0, these two properties were removed as flags in a separate Authentication instance and moved to the base class AuthenticationOptions. Properties can be configured by calling the AddAuthentication method in the ConfigureServices method Startup.cs
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme);
Alternatively, use the overloaded version of the AddAuthentication method to set more than one property. In the following overloaded method example, the default scheme is set to CookieAuthenticationDefaults.AuthenticationScheme. An authentication scheme can alternatively be specified in your individual [Authorize] attributes or authorization policies.
services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; });
Define a default schema in 2.0 if one of the following conditions is true:
- You want the user to automatically subscribe to
- You use the [Authorize] attribute or authorization policies without specifying a scheme
An exception to this rule is the AddIdentity method. This method adds cookies for you and sets the default authentication and calling patterns in the cookie of the IdentityConstants.ApplicationScheme application. In addition, it sets the default login scheme for the external cookie IdentityConstants.ExternalScheme .
Hope this helps you.
Sergey
source share