Hi everyone,
I’m encountering an issue with Keycloak regarding refresh token invalidation and would appreciate any insights.
Background:
- I have Keycloak set up with a custom user federation plugin for one of my clients, and it’s working well overall. We’re not syncing users over to Keycloak; instead, we only validate them upon login.
- A new requirement mandates that only one active session per user exists in our application at any given time.
- Our plan was to implement session limitation using Keycloak, employing short expiry for access tokens and long expiry for refresh tokens, along with a custom authentication flow to terminate older sessions upon user login.
- We created a custom flow with session termination, but it isn’t functioning as expected.
What We’ve Observed:
- In our basic tests—both in our application and via Postman and script—logging in twice allows us to successfully use refresh tokens from both sessions to fetch new access tokens.
- The user details page doesn’t list any sessions for that user, yet all sessions appear under the “Sessions” tab in the side panel. These sessions include a link to the user, which then redirects to their session tab displaying an empty list.
- Manually revoking the offline session for the app seems to work as intended.
There appears to be a disconnect between what’s shown under user sessions and what’s actually occurring in the sessions panel. Has anyone experienced similar behavior, or do you have any suggestions on what might be going wrong? Any advice on how to properly enforce single active sessions with refresh token invalidation would be greatly appreciated.
Thanks in advance for your help!