Repository navigation
Check if TwoFactorRememberMeScheme is registered before signing out - #68571
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an Identity regression introduced in .NET 7 where SecurityStampValidator<TUser> would unconditionally attempt to sign out IdentityConstants.TwoFactorRememberMeScheme, causing an InvalidOperationException when that scheme wasn’t registered (common with minimal AddIdentityCore configurations).
Changes:
- Update
SecurityStampValidator<TUser>.ValidateAsyncto check whetherTwoFactorRememberMeSchemeis registered before callingSignOutAsyncfor that scheme. - Update existing unit tests to register a scheme provider in the test DI container when the 2FA remember-me sign-out is expected.
- Add a new unit test covering the “scheme not registered” scenario to ensure sign-out is not attempted.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Identity/Core/src/SecurityStampValidator.cs | Guards the TwoFactorRememberMeScheme sign-out behind a scheme registration check to prevent exceptions when the scheme isn’t configured. |
| src/Identity/test/Identity.Test/SecurityStampValidatorTest.cs | Adjusts existing tests for the new scheme-provider dependency and adds a regression test ensuring no sign-out when the scheme isn’t registered. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
javiercn
approved these changes
Aug 17, 2026
Member
Author
|
/backport to release/11.0-rc1 |
Contributor
|
Started backporting to |
Merged
11 tasks
akoeplinger
pushed a commit
that referenced
this pull request
Aug 17, 2026
…68571) (#68577) Co-authored-by: Youssef Fahmy <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #47368
The scenario regressed in .NET 7 in #38262, which unconditionally attempts to signout
TwoFactorRememberMeScheme.This PR checks first if
TwoFactorRememberMeSchemewas registered before attempting to signing out.