question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to expire “ApplicationCookie” in aspboilerplate

See original GitHub issue

I am using version 2.3(angularjs). I can call methods when logout the program. Like the photo below: Capture I use the following code to logout

AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); when logout the program but claim and cookie not expire

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
alirezawillscommented, Mar 9, 2021

@mehdiali22 @demirmusa @gterdem I solved the problem using the following code in startup.cs: app.CreatePerOwinContext(() => IocManager.Instance.Resolve<UserManager>());

and

app.UseCookieAuthentication(new CookieAuthenticationOptions
  {
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
SlidingExpiration = true,
ExpireTimeSpan = TimeSpan.FromMinutes(16),
CookieHttpOnly = true,`

            Provider = new CookieAuthenticationProvider
            {

                OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<UserManager, User, long>(
            validateInterval: TimeSpan.FromSeconds(1),

            regenerateIdentityCallback: (manager, user) => manager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie),
            getUserIdCallback: claimsIdentity => ClaimsIdentityExtensions.GetUserId(claimsIdentity).Value)

            }


        });

Why is this problem not fixed for this framework? Anyway, thank you all

0reactions
mehdiali22commented, Mar 1, 2021

@mehdiali22 @demirmusa @gterdem I solved the problem using the following code in startup.cs: app.CreatePerOwinContext(() => IocManager.Instance.Resolve<UserManager>());

and app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), SlidingExpiration = true, ExpireTimeSpan = TimeSpan.FromMinutes(16), CookieHttpOnly = true,

        Provider = new CookieAuthenticationProvider
        {

            OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<UserManager, User, long>(
        validateInterval: TimeSpan.FromSeconds(1),

        regenerateIdentityCallback: (manager, user) => manager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie),
        getUserIdCallback: claimsIdentity => ClaimsIdentityExtensions.GetUserId(claimsIdentity).Value)

        }


    });`

Why is this problem not fixed for this framework? Anyway, thank you all

Thanks Alireza so much. It works. I hope ABP team solve this problem in their project ASAP.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting expiration for cookie on claims based authentication
ApplicationCookie, LoginPath = new PathString("/Account/Login"), Provider = new CookieAuthenticationProvider { ExpireTimeSpan = TimeSpan.
Read more >
OnValidateIdentity logs off all users #5255
ApplicationCookie ), getUserIdCallback: (ci) => (Int64.Parse(ci.GetUserId()))) }, SlidingExpiration = true, ExpireTimeSpan = TimeSpan.FromMinutes ...
Read more >
How to setup password expiration using ASP.NET Identity ...
[Solved]-How to setup password expiration using ASP. ... defaultauthenticationtypes.applicationcookie); // add custom user claims here return useridentity; ...
Read more >
Account Confirmation & Password Recovery - ASP.NET ...
Account confirmation and password recovery with ASP. ... ApplicationCookie); // Add custom user claims here return userIdentity; } }.
Read more >
Adding minimal OWIN Identity Authentication to an Existing ...
ASP.NET 4 provides a new Identity Authentication/Authorization ... ApplicationCookie, LoginPath = new PathString("/Account/LogOn") }); app.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found