1

So in my application I've configured the identity as:

services.ConfigureApplicationCookie(cfg =>
            {
                cfg.Cookie.Name = "application_ms_state";
                cfg.Cookie.Expiration = TimeSpan.FromDays(1);
                cfg.SlidingExpiration = true;
            });

but the expiration happens in almost 20 minutes.could anyone shed some light on this?

Behnam Esmaili
  • 5,835
  • 6
  • 32
  • 63

2 Answers2

4

After days of searching thanks to guys behind this answer i figured out that the problem is ,identity checks every 30 minutes (by default, its configurable) to see if issued authentication ticked is valid, consequently it checks to see if the class which is implementing UserStore<> is implementing IUserSecurityStampStore (UserManager.SupportsUserSecurityStamp) for that matter. As my MembershipService class which is implementing IUserStroe does not implement IUserSecurityStampStore<> thus after 30 min interval i end up with invalid security stamp and a null principal which == SignOut.

check this github issue to get a reference for mentioned code snippets.

Behnam Esmaili
  • 5,835
  • 6
  • 32
  • 63
1

Read the doc comments. https://github.com/aspnet/Security/blob/a53bf093a7d86b35e019c80515c92d7626982325/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs#L147 ExpiresTimeSpan and Expiration control different things. ExpiresTimeSpan is the one used for sliding expiration.

Tratcher
  • 5,929
  • 34
  • 44
  • i applied `ExpiresTimeSpan` and waiting for the result.i'll mark u as answer after 40 mins or so if i didn't log out after that time span :D. – Behnam Esmaili Sep 13 '17 at 11:54
  • i mark you as answer because it's more likely to be the common problem but posting my own answer for those who just in case face similar problem.thanks in advance for sticking to problem. – Behnam Esmaili Sep 14 '17 at 15:40