8000 Add support for overriding offline session lifespan values by thomasdarimont · Pull Request #24302 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Add support for overriding offline session lifespan values - #24302

Closed
thomasdarimont wants to merge 3 commits into
keycloak:mainfrom
thomasdarimont:poc/ispn-lifespan-override
Closed

thomasdarimont wants to merge 3 commits into
keycloak:mainfrom
thomasdarimont:poc/ispn-lifespan-override

Conversation

@thomasdarimont
Copy link
Copy Markdown
Contributor

See: #24274

Signed-off-by: Thomas Darimont thomas.darimont@googlemail.com

See: keycloak#24274

Signed-off-by: Thomas Darimont <thomas.darimont@googlemail.com>
Signed-off-by: Thomas Darimont <thomas.darimont@googlemail.com>
- We now take the configured realm values into account
- Made InfinispanUserSessionProviderFactory a ServerInfoAwareProvider to expose the detailed configuration
@ahus1
ahus1 commented Jan 30, 2024
Copy link
Copy Markdown
Member

Hi @thomasdarimont - we're considering your solution and are are currently making up our minds which automated tests we would add to it.

As this PR is already some months old, do you have some ideas / thoughts / code you would like to add?

thomasdarimont commented Jan 30, 2024 •
Copy link
Copy Markdown
Contributor Author

Hey @ahus1 thanks for the heads up! That's awesome news :)

Some ideas:

In my PR, I introduced dedicated settings for offlineSessionCacheEntryLifespanOverride and offlineClientSessionCacheEntryLifespanOverride. Perhaps instead of providing those settings, we could leverage the infinispan configuration directly, e.g., we could use the max-idle configuration of the corresponding infinispan cache. This allows users to customize and adjust the cache behavior according to their needs.

Most users who need to customize the cache behavior want to reduce memory usage over time, especially when many offline sessions are at play. Those users will probably adjust the max-idle time of the offline user/client sessions cache to be ~10 hours to cover a workday or 24 hours to cover a full-day travel experience in a travel companion app.

The current default cache-ispn.xml file does not specify a max-idle, hence it uses either the internal default (-1) or a Keycloak controlled value. Perhaps we could make Keycloak inspect the provided cache configuration, and if we detect that the admins configured max-idle differently than the default, we could use that. :)
However, since this would apply to the server globally that might not always be enough...
So we might need some explicit configuration options in the admin ui under realms/sessions here like:
-> configures max-idle for a cache entry in seconds (translated to milliseconds internally)

  • user session cache lifespan
  • offline session cache lifespan
    This would allow admins to configure max-idle times per realm.

@ahus1
ahus1 commented Jan 30, 2024
Copy link
Copy Markdown
Member

Hi @thomasdarimont - thank you for the comment. We prefer documented options instead of a long XML file where people might get lost. Due to this, we prefer the SPI-parameters. Maybe we'll eventually have a CLI option for it.

About the max-idle in the XML: As we're passing the lifetime and idle via the Java API, I was under the assumption that those would take precedence?

Having that configurable via the UI per realm would be a next step. Let's take it one step at a time.

@ahus1
ahus1 commented Feb 9, 2024
Copy link
Copy Markdown
Member

Closing in favor of #26811

@ahus1 ahus1 closed this Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0