【发布时间】:2021-10-04 00:41:57
【问题描述】:
我已经使用 OpenId Connect 在 ASP.NET MVC 项目中配置了 Azure AD 身份验证。身份验证有效,但问题是,60 分钟后会话不再有效。在我的应用程序中,用户闲置一段时间是很常见的,并且应该能够继续工作而无需重新登录。这就是我在 Startup.auth.cs 中设置身份验证的方式:
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions {
CookieManager = new SystemWebCookieManager()
});
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = Authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications()
{
AuthorizationCodeReceived = (context) =>
{
return System.Threading.Tasks.Task.FromResult(0);
}
}
});
我已尝试按照https://www.cloudidentity.com/blog/2016/07/25/controlling-a-web-apps-session-duration-2/ 的建议添加会话刷新逻辑。这种方法的问题是登录窗口不能显示在框架中。
如何在用户关闭浏览器窗口之前保持会话有效?这似乎是一个常见问题,应该有一些常见的解决方案,但我找不到。
【问题讨论】:
标签: c# .net asp.net-mvc azure-active-directory openid-connect