Skip to content

[Upgrade to .Net7] SecurityStampValidator<TUser> forces signout of TwoFactorRememberMeScheme which leads to InvalidOperationException in case scheme is not registered #47368

Open
@plachor

Description

@plachor

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hi, in my project I'm relaying on AddIdentityCore followed by checrrypicked registrations like AddSignInManager and etc. It allows me to setup minimal Identity for my project. I do not want roles nor I do not want default authentication schemes.

Till now I have not yet invested in MFA or 2FA as most of users of this product are authenticated through external authentication scheme (which supports MFA).

So I have custom authentication schemes. (OpenIdConnect, Cookie and External for SSO). However I do not have TwoFactorRememberMeScheme as I do not use it. I've tried to bump my project to .NET7 from .NET6. However it turns out that in .NET7 default SecurityStampValidator<TUser> is forcing sign-out of TwoFactorRememberMeScheme scheme.

This ends with InvalidOperationException as there is no handler registered for that scheme. Check: https://github.com/dotnet/aspnetcore/blob/main/src/Identity/Core/src/SecurityStampValidator.cs#L137

Expected Behavior

Since you allow minimal setup as AddIdentityCore is public and not obsolete than perhaps you should not enforce some hard-coded scheme sign-out. in default implementation of SecurityStampValidator

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

7.0.201

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pillar: Technical Debtarea-identityIncludes: Identity and providersbugThis issue describes a behavior which is not expected - a bug.cost: XSWill take up to half a day to completetriaged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions