OnValidateIdentity disables the MVC OWIN remember me option

后端 未结 3 972
太阳男子
太阳男子 2021-01-15 04:08

When I activate the OWIN logout-everywhere feature via security stamps and use the OnValidateIdentity-Callback of the CookieAuthenticationProvider

相关标签:
3条回答
  • 2021-01-15 04:40

    I have found the following code in the disassembly of SecurityStampValidator.OnValidateIdentity:

    // .. some other code
    // ...
    ClaimsIdentity claimsIdentity = await regenerateIdentityCallback(userManager, tUser);
    if (claimsIdentity != null){
    context.get_OwinContext().get_Authentication().SignIn(new ClaimsIdentity[]
        {
           claimsIdentity
        });
    }
    

    It seems to me, that the SignIn-operation is incomplete and should set the remember-me option? Therefore I assume that the implementation of SecurityStampValidator is buggy.

    0 讨论(0)
  • 2021-01-15 04:42

    This is resolved in ASP.NET Identity 2.2. See https://aspnetidentity.codeplex.com/workitem/2319

    0 讨论(0)
  • 2021-01-15 04:53

    This is basically a bug, the regeneration of the cookie should respect the current Remember Me option on the cookie. As a workaround, you can copy the OnValidateIdentity code and feed in the current context properties to flow the Persistent mode through:

    context.OwinContext.Authentication.SignIn(context.Properties, identity);
    
    0 讨论(0)
提交回复
热议问题