我正在开发用于登录和注销(Spring 启动)的 Api。
要求用户只能在 5 台设备上登录。
我如何使用 spring boot 实现这个?
最佳答案
在设备的情况下,如果您只允许 5 个注册设备能够登录,那么您必须在数据库中维护它。
但是,如果您希望最多 5 台设备能够同时登录,请尝试此操作 - https://docs.spring.io/spring-session/docs/current-SNAPSHOT/reference/html/spring-security.html#spring-security-concurrent-sessions
使用 maximumSessions(5)
http
// other config goes here...
.sessionManagement()
.maximumSessions(5)
这将只允许同一用户一次进行 5 个 session
关于java - 如何在 Spring Boot 中限制仅 5 个设备的登录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59960581/