I am using the default cookie based authentication in .Net 6. On successful authentication application is setting up cookie with sliding expiration as true as I want to refresh the token periodically. Frontend of application is also storing the initial expiry time of the above server side cookie to control certain client side functionalities and I have a requirement to refresh that expiry time when server refresh the cookie due to periodic refresh. For this requirement I am trying to make an endpoint which doesn't refresh the cookies and in return pass the expiry time of current cookie. For developing on this requirement I am trying to override only CheckForRefreshAsync function in CookieAuthenticationHandler which I am unable to do.
Below is the code where I am adding the authentication module -
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.ExpireTimeSpan = TimeSpan.FromMinutes(30);
options.Cookie.Name = "app-cookie";
options.Cookie.SameSite = SameSiteMode.Strict;
options.Cookie.Domain = "xyz.com";
options.Cookie.MaxAge = options.ExpireTimeSpan;
options.SlidingExpiration = true;
options.EventsType = typeof(CustomCookieAuthenticationEvents);
});
Looking forward for any lead in creating the endpoint which doesn't refresh the server side cookie but only return the expiry time of current cookies.