Files
dotnet-runtime/src/libraries/System.Security.Claims
ee87a97e25 [release/5.0-rc2] Return null from ClaimsPrincipal.Current if no thread principal. (#42638)
* Return null from ClaimsPrincipal.Current if no thread principal.

In the .NET Framework, the AppDomain's default PrincipalPolicy is
UnauthenticatedPrincipal. When falling back to the thread's principal,
this would no throw because a GenericPrincipal was returned.
If the policy was changed to NoPrincipal, ClaimsPrincipal.Current would
throw constructing the ClaimsPrincipal since there is no principal.
However that behavior was opt-in.

In .NET Core, the default policy was changed to NoPrincipal, which would
mean unless a principal was explicitly set, Current would always throw.

This changes the behavior to return null instead of throw for
NoPrincipal. This is to continue supporting the existing behavior in
.NET Core 3 of returning null if there is no principal, but continue
to allow falling back to the thread's principal.

* Code review feedback.

Co-authored-by: Stephen Toub <[email protected]>

* Fix typos

Co-authored-by: Kevin Jones <[email protected]>
Co-authored-by: Stephen Toub <[email protected]>
2020-09-23 23:07:08 -07:00
..