Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep IPrincipal user instances if not ClaimsPrincipal #343

Merged
merged 5 commits into from
May 26, 2023

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.

2 participants