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

Ensure the anonymous principal is not authenticated #373

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

StephenCWills
Copy link
Member

Resolves an issue with the anti-CSRF token validator.

When generating a form token, the token validator uses IIdentity.IsAuthenticated to determine whether to encode a username in the token. Due to the changes in #363, the Login.cshtml page was encoding the username "anonymous" in its form token. When validating the form token for the AuthTest page, the validator was expecting an empty username.

GenericIdentity is authenticated so long as it has a name. Therefore, it is impossible to use GenericIdentity to get an identity with the name anonymous that is not authenticated. ClaimsIdentity is authenticated so long as it has an authentication type so we can simply pass a name claim with no authentication type into the constructor.

@StephenCWills StephenCWills merged commit 5e75700 into master Feb 13, 2025
2 checks passed
@StephenCWills StephenCWills deleted the anon-noauth branch February 13, 2025 21:49
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