每个帐户只允许一个会话

Allow only one session per each account

我在我的开发环境中使用 CAS 5.3,我希望每个帐户只允许一个会话。如果任何人尝试使用相同的凭据登录并且之前的会话仍未被破坏,那么系统应该向当前正在尝试使用某某 ip 的用户提示一个警报,你已经登录并且你想破坏会话以登录。如果用户确认他们系统应该销毁较早的会话并允许当前用户登录。

我已经查看了 CAS 文档,但我能够找到解决方案。你能帮我解决这个问题吗?早些时候我使用的是 CAS 旧版本,因为我修改了 CAS 提供的源代码。有了这个实现它。但我不知道如何在 CAS 5 中做同样的事情。

I want allow only one session per each account. If any one trying to login with same credentials and earlier session is still not destroyed then system should prompt an alert ...

从 CAS 5.2.x 开始,身份验证策略可用 "Unique Principal",根据文档是这样做的:

Satisfied if and only if the requesting principal has not already authenticated with CAS. Otherwise the authentication event is blocked, preventing multiple logins.

它还指出:

Activating this policy is not without cost, as CAS needs to query the ticket registry and all tickets present to determine whether the current user has established a authentication session anywhere. This will surely add a performance burden to the deployment. Use with care.

因此,您可以先配置它,然后修改或扩展它以满足您的确切需求。

可以找到更多信息in the CAS docs