Skip to content

Check if TwoFactorRememberMeScheme is registered before signing out - #68571

Merged
Youssef1313 merged 1 commit into
mainfrom
dev/ygerges/check-before-signout
Aug 17, 2026
Merged

Youssef1313 merged 1 commit into
mainfrom
dev/ygerges/check-before-signout

Conversation

@Youssef1313

Copy link
Copy Markdown
Member

Fixes #47368

The scenario regressed in .NET 7 in #38262, which unconditionally attempts to signout TwoFactorRememberMeScheme.

This PR checks first if TwoFactorRememberMeScheme was registered before attempting to signing out.

Copilot AI lite review requested due to automatic review settings August 17, 2026 08:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>.ValidateAsync to check whether TwoFactorRememberMeScheme is registered before calling SignOutAsync for 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.

@Youssef1313
Youssef1313 requested a review from halter73 August 17, 2026 08:11
@Youssef1313
Youssef1313 merged commit b1764f8 into main Aug 17, 2026
28 checks passed
@Youssef1313
Youssef1313 deleted the dev/ygerges/check-before-signout branch August 17, 2026 10:25
@Youssef1313

Copy link
Copy Markdown
Member Author

/backport to release/11.0-rc1

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0-rc1 (link to workflow run)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants