【发布时间】:2015-06-05 05:05:07
【问题描述】:
我们有一个使用 OWIN Cookie 身份验证的 ASP.NET MVC 5 应用程序,具有滑动到期。在客户端,我们有一个脚本,它每分钟轮询 Web 服务以获取通知。我们希望防止该 Web 服务调用导致身份验证令牌过期向前滑动。有什么办法吗?
我正在考虑在 OnValidateIdentity 处理程序中实现我自己的自定义滑动到期方法,但在该方法中设置 ExpiresUtc 似乎并不会真正影响令牌的到期日期。
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = cookieValidateIdentityContext =>
{
cookieValidateIdentityContext.Properties.ExpiresUtc = DateTime.UtcNow.AddMinutes(-1);
return Task.FromResult(0);
}
},
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
AuthenticationMode = AuthenticationMode.Active,
LoginPath = new PathString("/"),
SlidingExpiration = false,
LogoutPath = new PathString("/Sessions/Logout")
});
感谢任何帮助!
【问题讨论】:
标签: c# asp.net-mvc owin