Issue
I am working on an Api for login and logout (Spring boot).
There is requirement that an user is allowed to login only in 5 devices.
How i can implement this using spring boot?
Solution
In the case of device if you allow only 5 registered device to be able login than you have to maintain it in database.
But if you want any at most 5 device able to login at same time than try this - https://docs.spring.io/spring-session/docs/current-SNAPSHOT/reference/html/spring-security.html#spring-security-concurrent-sessions
use maximumSessions(5)
http
// other config goes here...
.sessionManagement()
.maximumSessions(5)
This will allow only 5 session at a time for same user
Answered By - Meet Patel
Answer Checked By - Cary Denson (JavaFixing Admin)