Home > Software engineering >  Keycloak user's active session information
Keycloak user's active session information

Time:07-04

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.

CodePudding user response:

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 enter image description here

  • Get the list of "Account-console" client ID enter image description here

  • Get the it's users session enter image description here

  • It should be match with Keycloak UI's client session information enter image description here

    1. if you want to prevent a deletion session of user, remove assigned realm management role enter image description here

    Then he/she can't call remove a user session API "Remove a specific user session" DELETE /{realm}/sessions/{sessionId}

    • Related