diff --git a/aspnetcore/security/authentication/index.md b/aspnetcore/security/authentication/index.md index 07f1eb90c647..b40c947fa65d 100644 --- a/aspnetcore/security/authentication/index.md +++ b/aspnetcore/security/authentication/index.md @@ -48,13 +48,22 @@ The Authentication middleware is added in `Program.cs` by calling for authorization to make permission decisions against. There are multiple authentication scheme approaches to select which authentication handler is responsible for generating the correct set of claims: * [Authentication scheme](#authentication-scheme) -* The default authentication scheme, discussed in the next section. +* The default authentication scheme, discussed in the next two sections. * Directly set . -There's no automatic probing of schemes. If the default scheme isn't specified, the scheme must be specified in the authorize attribute, otherwise, the following error is thrown: +When there is only a single authentication scheme registered, it becomes the default scheme. If multiple schemes are registered and the default scheme isn't specified, a scheme must be specified in the authorize attribute, otherwise, the following error is thrown: > InvalidOperationException: No authenticationScheme was specified, and there was no DefaultAuthenticateScheme found. The default schemes can be set using either AddAuthentication(string defaultScheme) or AddAuthentication(Action\ configureOptions). +### `DefaultScheme` + +When there is only a single authentication scheme registered, the single authentication scheme: + +* Is automatically used as the `DefaultScheme`. +* Eliminates the need to specify the `DefaultScheme` in `AddAuthentication` or . + +To disable automatically using the single authentication scheme as the `DefaultScheme`, call `AppContext.SetSwitch("Microsoft.AspNetCore.Authentication.SuppressAutoDefaultScheme")`. + ### Authentication scheme The [authentication scheme](xref:security/authorization/limitingidentitybyscheme) can select which authentication handler is responsible for generating the correct set of claims. For more information, see [Authorize with a specific scheme](xref:security/authorization/limitingidentitybyscheme).