aspnet / Announcements

Subscribe to this repo to be notified about major changes in ASP.NET Core and Entity Framework Core
Other
1.66k stars 80 forks source link

[Breaking change]: AuthenticateAsync for remote authentication providers no longer fails if anonymous #491

Open Tratcher opened 2 years ago

Tratcher commented 2 years ago

Description

RE: https://github.com/dotnet/aspnetcore/issues/43042, https://github.com/dotnet/aspnetcore/pull/43212

Remote authentication providers like OpenIdConnect, WsFederation, and OAuth have been updated to avoid unnecessary errors when there is no user information available on the request.

Version

.NET 7 RC1

Previous behavior

When AuthenticateAsync was called on a remote authentication provider and there was no current user, this call would fail with a message like OpenIdConnect was not authenticated. Failure message: Not authenticated.

New behavior

AuthenticateAsync will now return AuthenticateResult.NoResult(), an anonymous identity.

Type of breaking change

Reason for change

Recommended action

Code that directly invokes AuthenticateAsync should be checked to ensure it properly handles AuthenticateResult.NoResult() and anonymous/empty ClaimsIdentity's.

Affected APIs

HttpContext.AuthenticateAsync