Repository navigation
Keycloak 26 : cookies error with Idp SAML #35397
|
Hi, We just upgraded keycloak to 26. After the upgrade it is impossible to login with keycloak as broker and azure IDP. We get a 400 on the post request comming from microsoft and a cookie not found. "Please make sure cookies are enabled in your browser" As i undertand it Keycloak cookies KC_ are set with sameSite Lax which block the request. Why those cookies are set to lax ? Is there a way to force samesite to none ? |
Replies: 6 comments 13 replies
|
This has been reported as an issue under #34295, I suggest you subscribe there. This is likely an improper proxy configuration causing the Keycloak server to be served from an insecure context, causing the cookie to not be available. Please make sure to follow the upgrade guide and check out the hostname (v2) and reverse proxy guides. |
|
Ok it seems KC_PROXY_HEADERS xforwarded was missing. Now login is working but logout fails :-(. I will investigate |
|
For those running into this issue:
If you are still having issues follow https://www.keycloak.org/server/hostname#_troubleshooting to verify that Keycloak is aware of the correct URLs, and most importantly the scheme. See https://www.keycloak.org/server/reverseproxy and https://www.keycloak.org/server/hostname for more details. The reason why people are having issues with 26 is there are two changes there:
Additionally, what makes this a bit more complicated is that browsers consider http://localhost/ a secure context ;) If anyone still is having issues after this, try enabling trace logging for org.keycloak.cookie.DefaultCookieProvider. That will print a statement for what cookies Keycloak receives, and if you drop us that list as well as when you have the problem. Is it on the first request to Keycloak after SAML redirect? Also, are you using SAML GET or POST? |
|
I came here form the GHI, in my case I'm still back in 24.0.5 and I see issues only in our PROD instance that is setup the exact same way. Just to clarify on your comment about the headers @stianst if I'm using the operator have: This should take care of it correct? Left = our prod, right = our testing env, the prod one is setting "Strict" in the cookie no even lax, the test one sets NONE, also not lax. We can't upgrade to any version =>25 yet, we are waiting for a PR I submitted here to be merged: #30669 but the PR as been reviewed and approved yet not merged.. no need to get into the detail of that but its only a problem in Gcloud SQL if on 5.7 or WHEN replication is enabled regardless of its 5 or 8. We actually tried to move to Postgress even but migrations are not supported natively and we did run into multiple issue. So we not only did all efforts to upgrade but I even tested the problem in multiple scenarios and created a PR that should ensure this always works but not using With that said I still want to figure out why this can act different other than the headers because as you can see in the image the flag is set. Is there anything at DB level maybe that can override it? Or some realm settings (though I did check all and other then clients and users we share all the same configs). Also what level should I enable for |
|
We've finally upgraded our envs to mysql 8 and KC 26, but this issue still exists in our prod env, unless I disable WAAS. Here is the info we see in the debug page: This cookie is set as "Strict": Without the WAAS (prisma cloud) in place this doesn't happen and SameStie=None and I also don't have "X-Forwarded-For" header My guess is that this might be due to "X-Forwarded-Host" but I'm not sure. Is there something that can be done in KC side or is this a issue with the WAAS software / ingress? |
|
I'm experiencing the same issue when using Keycloak 26.2.4 with Azure SAML IDP. During login, the following error occurs: For previously logged-in users, it shows: However, for users who have never logged in before, everything works fine. Then when I added the following directive to my Nginx reverse proxy configuration: proxy_cookie_flags ~.* secure samesite=None; everything started working normally. version: '3.9' |
For those running into this issue:
If you are still having issues follow https://www.keycloak.org/server/hostname#_troubleshooting to verify that Keycloak is aware of the correct URLs, and most importantly the scheme.
See https://www.keycloak.org/server/reverseproxy and https://www.keycloak.org/server/hostname for more details.
The reason why people are having issues with 26 is there are two changes there: