Repository navigation
Replies: 19 comments 99 replies
|
The first set of features are now available in the nightly build. I've updated the description. |
|
Is Keycloak with It will use the database cache, so we hope it would run reasonable fast. If this is case, it would simplify the code of Keycloak a lot, and the data would always be consistently stored in Keycloak's database, and you need to worry less about Keycloak's JVM memory usage. Please comment here with your findings - possibly with your logins per second and number of concurrent user sessions. Thanks! |
|
Some production statistics :
count from ISPN database persistence (right now with the hacky
8 vCPU / 32 Go RAM, huge JVM around 20 Go (way too big, it has to be reviewed following recent guide and benchmark results) with most of users and user sessions in cache. CPU usage is low on both instances (KC & database), they are oversized for current trafic. NOTE: delay to get a refresh token has increased a lot between KC 20 and KC 22, from 40 ms to 220 ms with the same infrastructure, a little bit more sessions but not too much. We did not take time to investigate more on this. |
|
I've been tracking this discussion and its tendrils across github, trying to figure out what problem "persistent user sessions" solves to begin with.... Or to be honest, if it adressess a specific use case of mine: Will this feature allow users to remain offline for a "long" time (say 30 days), and be able to silently log back in again? (the goal being to make it as easy as possible for the user to continue using the application). From what I understand, this can be mimicked by misuing an offline token, but I also have been told that this is not what offline tokens are meant for (which is that they are meant for executing authorized tasks when the user is not online) and may introduce unneccessary security risks. Thinking about it, it seems that there is always additional risk involved by allowing this (since a token or some sort of password must always be stored on the, potentially vulnerable, client, but it seems to be acceptable for big apps like Gmail, and even secure apps like Protonmail. Thanks for any clarification! |
|
@mhajas @ahus1 Really happy to see the progress on this. Per #27976 (comment) I'm curious if this will also (eventually) encompass User Sessions, Authentication Sessions, User Login Failures, and Single Use Objects. We have a similar experiment for all the "cached" objects using JPA via the |
|
Hi All, We use Keycloak, and currently, version 23.0.7 is live. Our issue is that the session breaks when we modify a theme during a new deployment (unfortunately, every update for us involves theme modification), causing sessions to be cleared and users to be logged out, which is very inconvenient. We believe that #28271 would solve our problem. Therefore, our question is, when can we expect the deployment of this ticket? We tested the nightly, and it looks fine prefer not to deploy nightly builds into production Is there any plan that when you will deliver this development? :) Thank you in advance for your assistance and information :) |
|
Will this change also allow (or at least make it easier) to display recently expired sessions for users in the account console? I am assuming that since Infinispan is a cache, it's a bit harder to query for all user sessions, including expired ones, and clearing the information from the cache as soon as possible is best. It would be a pretty good boon from a security standpoint to be able to review recent user sessions, similar to how Microsoft displays such information. |
@ahus1 If the account REST API is still there for this then I guess it wouldn't hurt to add this function back in. If the REST API is missing then that probably means someone had a very good reason for getting rid of it. Maybe open a discussion on the dev list? |
|
I don't have much to add other than that this would be well received by our users. |
|
Works so far 👍, but didn't do comprehensive tests, yet. Is there any chance that the |
|
I was under the impression that when you enable the persistent sessions feature, you can switch the cache type to local. |
|
Getting this error intermittently every few hours after enabling persistent user sessions on 25.0.2 ERROR [org.hibernate.orm.jdbc.batch] (org.keycloak.models.sessions.infinispan.changes.PersistentSessionsWorker$BatchWorker) HHH100501: Exception executing batch [org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; statement executed: update OFFLINE_USER_SESSION set BROKER_SESSION_ID=?,CREATED_ON=?,DATA=?,LAST_SESSION_REFRESH=?,REALM_ID=?,USER_ID=?,version=? where OFFLINE_FLAG=? and USER_SESSION_ID=? and version=?], SQL: update OFFLINE_USER_SESSION set BROKER_SESSION_ID=?,CREATED_ON=?,DATA=?,LAST_SESSION_REFRESH=?,REALM_ID=?,USER_ID=?,version=? where OFFLINE_FLAG=? and USER_SESSION_ID=? and version=? |
|
Hi, I tried to jump from v21.1.1 to 25.0.2 and there seems to be a blocker for this on my test env. I had a bit of trouble at first as updating my external ispn (managed by kubernetes operator) would redeploy and blank my sessions when updated to 15. I then tried to do the upgrade process without updating the ISPN version and staying on 14.0.9 ISPN. So, my sessions are created by 21.1.1 in ISPN 14 and get consumed from that same setup on the 25 startup. However, the conversion failed and I see an error message I traced this to https://github.com/keycloak/keycloak/pull/17525/files#diff-1445188baf4e2f8d90de96fc76d0423dd86425d2a0a9ede5c3e20d88c3f85077 on line 94 where the client id is set in v22+. So, likely 22 is the lower bound for upgrading sessions. I'll also note that the docs say the table I did test the persistence on 25 between total restarts and that works! tyty. Lastly, I'm trying to set some expectations for the stake holders about actual real life session persistence. Clearly the sessions are based on class definitions within KC - so, if we really want full persistence, we cant change the classes. What can we expect for this? Can I say that persistence will work between major releases? minor? |
|
Anybody have success with Session transition with pretty large sets? Ie 300k+. Having issues that arent obvious how to fix. I posted an issue here : #32994. |
|
We are testing KC 26 for our deployment. let me give you a brief idea about our infra and usage. at present we are using kc 24.03. we use AWS EKS with single site deployment. we have minimum 3 nodes and 3 pods (m6i.large). we use external ISPN with mariadb for session persistence. we have around 11 million sessions keys in ispn. daily we have around 200k sessions. We use custom TCP stack for jgroup discoveries (tcpping). we firefight different issues that aries daily but managing such number sessions is the most challenging part. in our current deployment we see a issue that is in admin panel sessions are not showing(from user-> session) even through it exists in remote ispn because cache is refreshing client login is working as it should. but due to this problem 2 issues we are facing,
so when we found out 26 is offering session persistence by default we were very excited. but during our initial testing we found few strange behavior.
so here is my question, if sessions are persisted in db shouldn't all the pod have the data always ? and shouldn't all sessions are visible from user menu in admin? or do have to do something to make this work? |
|
I'm trying to apply it. But I get a driver error when configuring the database. Because I have one set in the keycloak .conf for the rest of the data. But it has to go in environment variables and when I put it I get this ( 2024-11-13 12:48:01,939 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Could not start server in (production) mode 2024-11-13 12:48:01,939 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Could not get JDBC connection 2024-11-13 12:48:01,939 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: The handler does not support the given URL: jdbc:mysql://localhost:3306/mowiz23keycloak?useSSL=false&allowPublicKeyRetrieval=true 2024-11-13 12:48:01,939 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) For more details, run the same command passing the '--verbose' option. You can also use '--help' to see details about using a particular command.) |
|
I have read all the documents related to HA and multi-site deployment, but I couldn't find a clear explanation for: "Why do I need an external Infinispan for multi-site deployment?" From what I understand, the default Keycloak already uses an internal Infinispan for caching. Restarting one instance should be safe since it will rebalance from the healthy ones, right? We have an active-active database setup with both data centers being writable (MariaDB). |
|
We are in a very old version of Keycloak (15.x) with around 4000 users and we are upgrading to 26.x. (2 Node Cluster). This instance is one of the [critical] moving parts of a large platform. While the upgrade went fine in QA, we notice that few of our OIDC clients randomly gets unauthorized error while calling the Token verification endpoint, and it goes away if we shutdown one of our nodes, indicating this might be an issue with session persistence. Below is our startup command:
Below is the startup log I also checked if database table Any pointers on troubleshooting this would be great. Thanks ! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
One of the biggest pain points of Keycloak is currently losing sessions on restarts. There were countless complaints on this, including a lot of workarounds that are usually unsupported and come with some trade-offs.
The current approach for storing sessions has become a blocker for active/active multi-site support that we are currently pursuing and therefore we needed to rethink this approach. While brainstorming a new approach we came up with a conclusion that we should also include durable sessions as that feature was already on our radar.
This is now part of Keycloak 25, see https://www.keycloak.org/docs/latest/upgrading/index.html#persistent-user-sessions for more details on how to migrate. Please provide your feedback here (where it works, and were it should be enhanced).
There is also a blog post Keeping users logged in with Keycloak 25 summarizing the changes.
In the code branch for Keycloak 26 which we use for our nightly builds, this is now enabled-by-default, and fully supported. If you choose to disable the feature, Keycloak will revert to the old functionality of storing sessions only in memory.
Idea
The current behavior of Keycloak is that online sessions are stored only in Infinispan while offline sessions are also stored in the database. Therefore, the new feature's main idea is to store online sessions in the same table structure.
Plans
To follow this work proceed to the following GitHub epic: #28265
Highlights of the Keycloak 25 release
How to test
Download Keycloak 25 or later
Run Keycloak with the
persistent-user-sessionsfeature. Proceed to the following guide on how to enable/disable Keycloak features.Example command in development mode:
To confirm that online sessions are stored in the database check the database table
offline_user_sessioncontains rows withoffline_flagcolumn equal to0.All reactions