Skip to content

Conversation

@twsouthwick
Copy link
Member

There are instances where people are using non-ClaimsPrincipal users in ASP.NET Core. This change will allow us to track that IPrincipal and surface it as needed as a ClaimsPrincipal.

This is mostly for use while migrating, as ideally they will switch to a ClaimsPrincipal based User, but will prevent information contained in the custom type from being lost.

There are instances where people are using non-ClaimsPrincipal users in ASP.NET Core. This change will allow us to track that IPrincipal and surface it as needed as a ClaimsPrincipal. This is mostly for use while migrating, as ideally they will switch to a ClaimsPrincipal based User, but will prevent information contained in the custom type from being lost.
@twsouthwick twsouthwick requested a review from Tratcher May 26, 2023 19:36
{
null => null,
ClaimsPrincipal claims => claims,
IPrincipal user => new ClaimsPrincipal(user),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be cached?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I don't think we need to. It's only used here in the case of a custom IPrincipal, which should be a somewhat fringe case and one we'd like them to move away from. I'll add some logging to flag these cases to le people know, as well as add a section in the docs to explain in more detail.

@twsouthwick twsouthwick merged commit 78b845d into main May 26, 2023
@twsouthwick twsouthwick deleted the tasou/keep-users-separate-if-needed branch May 26, 2023 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants