Issue
I'm using keycloak
for authentication and authorization
, I want to get the active session
information of the users or the user, but I couldn't find such information in the docs.
If there is an active session belonging to the user, I want to prevent this user from deleting it, so I need such information.
If we can't get the active session information, I can accept a different alternative answer.
I am using Spring boot
and keycloak version 15.0.2
.
Solution
You can get this API
"Get user sessions for client Returns a list of user sessions associated with this client"
GET /{realm}/clients/{sessionId}/user-sessions?first={startIndex}&max={numberUser}
It is located in https://www.keycloak.org/docs-api/15.0/rest-api/index.html
This is demo
It should be match with Keycloak UI's client session information
Then he/she can't call remove a user session API "Remove a specific user session" DELETE /{realm}/sessions/{sessionId}
Answered By - Bench Vue
Answer Checked By - Candace Johnson (JavaFixing Volunteer)