MVC 5用OWIN自动注销用户

MVC 5用OWIN自动注销用户

问题描述:

我回顾了一些关于这方面的帖子,但我仍然无法找到对我的问题的答案。 我试图为花费更多定义时间的用户创建自动注销。例如,如果我指定30分钟的网络应用程序需要自动注销用户。MVC 5用OWIN自动注销用户

我使用OWIN与MVC 5和我Startup.Auth类配置为:

app.UseCookieAuthentication(new CookieAuthenticationOptions 
             { 
              AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, 
              LoginPath = new PathString("/Account/Login"), 
              CookieSecure = CookieSecureOption.SameAsRequest, 
              SlidingExpiration = true, 
              ExpireTimeSpan = new System.TimeSpan(0, 0, expireMinutes, 0, 0), 
             }); 

也:

app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); 

     app.UseCookieAuthentication(new CookieAuthenticationOptions()); 




     app.UseWsFederationAuthentication(
      new WsFederationAuthenticationOptions 
      { 
       Wreply = WAADReturnURL, 
       Wtrealm = realm, 
       MetadataAddress = metadata, 

      }); 

     app.UseMicrosoftAccountAuthentication(
      new Microsoft.Owin.Security.MicrosoftAccount.MicrosoftAccountAuthenticationOptions() 
      { 
       ClientId = "xxxx", 
       ClientSecret = "xxxx", 


      }); 


     app.UseYahooAuthentication(
      new YahooAuthenticationOptions() 
      { 
       ConsumerKey = "xxxx", 
       ConsumerSecret = "xxxx", 
      }); 


     app.UseLinkedInAuthentication(
      new LinkedInAuthenticationOptions() 
      { 
       ClientId = "xxxx", 
       ClientSecret = "xxxx", 
      }); 

     app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() 
     { 
      ClientId = "xxxx", 
      ClientSecret = "xxxx", 
     }); 

     app.UseFacebookAuthentication(new Microsoft.Owin.Security.Facebook.FacebookAuthenticationOptions() 
     { 
      AppId = "xxxx", 
      AppSecret = "xxxx", 
     }); 

我使用WAAD和第三方供应商如Facebook, Linkedin ...

另外我的web.config我设置了以下配置:

<authentication mode="None"> 
</authentication> 

我审查后交也,但没有解决: MVC 5 Identity Automatic Logout

感谢

Startup.Auth.cs类设置SlidingExpirationfalse。如果设置为true,Identity auto将在指定的TimeSpan的后半部分创建一个新的应用程序Cookie,并自动登录用户。