2

I review some posts about that but I can't still find answer on my question. I trying to create auto log off for users who spent more then defined time. Example if I specified 30 min web app need to automatically log off user.

I am using OWIN with MVC 5 and my configuration in Startup.Auth class are:

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),
                                       });

and also:

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",
        });

I am using WAAD and third party providers such as Facebook, Linkedin...

Also my web.config I set following configuration:

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

I review following post also but without solution: MVC 5 Identity Automatic Logout

Thanks

Community
  • 1
  • 1
kat1330
  • 5,134
  • 7
  • 38
  • 61

1 Answers1

1

in your Startup.Auth.cs class set SlidingExpiration to false. If set to true, Identity auto creates a new Application Cookie in second half of specified TimeSpan and user is automatically signed in.

Shoaib Shakeel
  • 1,447
  • 18
  • 24