Luke
Luke

Reputation: 15

retrieve keycloak SSO session idle

I am using Keycloak 17 to authenticate.
I would like to warn the user about the session Idle timeout.
Is there a way to programmatically retrieve the SSO Session idle time from the configuration?

[Edit] After looking at the sources, I found this in RealmModel: realm.SsoSessionIdleTimeout, but I don't know how to reach its value after the user logged in.
I have tried with the keycloak object like in this example, which returns 0:
keycloak.tokenManager().refreshToken().getRefreshExpiresIn()

Upvotes: 1

Views: 1057

Answers (1)

Paul
Paul

Reputation: 334

As you mentioned, you can retrieve the value using myRealm.getSsoSessionIdleTimeout(). In order to pass it to the user you can set it in the access/id token using a oidc mapper.

You can see a simple example in this excellent repo.

Don't forget to add this mapper to your client/default scope otherwise it will not be included in the tokens.

Upvotes: 1

Related Questions