Skip to content

[Discussion] Single authentication scheme is treated as default scheme #42828

Open
@captainsafia

Description

@captainsafia

Starting in .NET 7 Preview 7, we introduced new behavior in the authentication area in ASP.NET Core to reduce boilerplate and help build sensible defaults into 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    announcementThis issue is an announcement about important functionality change (prevents auto-closing)area-authIncludes: Authn, Authz, OAuth, OIDC, Bearer

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions