dotnet / dotnet/dotnet-api-docs

`ClaimsPrincipal.Current` documentation incorrect for .net core (all versions)

Open
#4,213 1 comment 0 reactions 0 assignees View on GitHub
area-System.Security Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

The documentation for `ClaimsPrincipal.Current` says:
> By default, Thread.CurrentPrincipal is returned. You can change this behavior by setting the ClaimsPrincipalSelector property to specify a delegate to be called to determine the current principal.

That is true for the .NET Framework, but is not true for .NET Core or current .NET 5 previews.

The actual behavior for .net core is as follows:
> By default, null is returned. You can change this behavior by setting the ClaimsPrincipalSelector property to specify a delegate to be called to determine the current principal.

This is because `ClaimsPrincipalSelector` defaults to null (in all frameworks, as correctly documented), but in .NET Framework it has an internal fallback method `ClaimsPrincipal.SelectClaimsPrincipal()`, which uses Thread.CurrentPrincipal. That fallback does not exist in .NET Core.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.