且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么基于IdentityServer4的服务器在30分钟内超时,而在前30分钟内仅支持SSO?

更新时间:2022-02-07 22:32:43

mode777是正确的。此问题与IdentityServer4或OpenID Connect均无关。与AspNetCore.Identity有关。我发现此链接非常有用,并通过添加如下代码行解决了我的超时问题:

mode777 is right. This issue is not related to IdentityServer4 nor OpenID Connect. It's related to the AspNetCore.Identity. I find this link very helpful and solved my timeout issue by adding a line like this:

services.Configure<SecurityStampValidatorOptions>(options => options.ValidationInterval = TimeSpan.FromHours(24));

因此,发生了什么事情:默认间隔30分钟后,将向服务器发送请求通过用户安全戳检查。由于某种未知的原因,检查我的用户安全标记的逻辑认为该标记无效,因此调用SignInManager的SignOutAsync,这会杀死所有内容。我仍然不明白,我的用户安全标记从未更改!它不应该导致无效。现在,我将让我的应用程序具有更长的检查间隔,并密切注意安全标记。

So, what happened is this: After the 30 mins default interval, a request to the server will go through the user security stamp check. For some unknown reason, the logic that checks my user security stamp think the stamp is invalid and hence calls SignInManager's SignOutAsync, which kills everything. What I still don't understand is that my user security stamp is never changed! It shouldn't cause the invalidation. For now, I will let my application works with a much longer check interval, and will keep an eye on the security stamp.