It looks like MK. the answer does not allow the token update to be correctly processed when using the SlidingExpiration option.
As a workaround, instead of providing a custom cookie provider, it appears that you can provide a custom cookie manager and define your own methods for adding / removing cookies.
To make this simple in my case, I reuse the default cookie manager under the hood. (I cannot extend it, its methods are not redefined.)
Here is the code that ended with me:
using Microsoft.AspNet.Identity; using Microsoft.Owin; using Microsoft.Owin.Infrastructure; using Microsoft.Owin.Security.Cookies; using Microsoft.Owin.Security.DataProtection; using Owin; public class Startup { public void Configuration(IAppBuilder app) { var options = new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, SlidingExpiration = true, CookieManager = new CustomCookieManager() }; app.UseCookieAuthentication(options); } } public class CustomCookieManager : ICookieManager { private readonly ICookieManager ConcreteManager; public CustomCookieManager() { ConcreteManager = new ChunkingCookieManager(); } string ICookieManager.GetRequestCookie(IOwinContext context, string key) { return ConcreteManager.GetRequestCookie(context, key); } void ICookieManager.AppendResponseCookie(IOwinContext context, string key, string value, CookieOptions options) { SetupDomain(context, options); ConcreteManager.AppendResponseCookie(context, key, value, options); } void ICookieManager.DeleteCookie(IOwinContext context, string key, CookieOptions options) { SetupDomain(context, options); ConcreteManager.DeleteCookie(context, key, options); } private void SetupDomain(IOwinContext context, CookieOptions options) {
source share