Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keycloak 18 openid logout - 404 (due the 2800 characters limit in the HTTP query for the IIS server) #12179

Open
adnsimona opened this issue May 25, 2022 · 10 comments
Assignees

Comments

@adnsimona
Copy link

Describe the bug

Hi.

We've recently updated our keycloak to 18.0.0.
Everything worked fine, automatically, except the logout mechanism.
Our site was still using redirect_uri.
We updated the frontend to use the most recent keycloak-js.
Now it is sending post_logout_redirect_uri and id_token_hint correctly.

And here is the issue, the logout is resulted in a Server Error: 404
"
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
"

I read that the 18 keycloak now asks confirmation to logout. We are using a custom template for the client.
Do we miss the page for the logout confirmation from our template?
If so, where can I find a sample template for this?

Would be nice: to display the error message in the log, what is not found exactly.

Cheers,
Ádám

Version

18.0.0

Expected behavior

User logs out

Actual behavior

404

How to Reproduce?

Probably: Use a custom template from an older version.

Anything else?

No response

@adnsimona adnsimona added kind/bug Categorizes a PR related to a bug status/triage labels May 25, 2022
@adnsimona
Copy link
Author

adnsimona commented May 25, 2022

Though what leaves us puzzled, is the following from the keycloak documentation:
"It is possible to omit the confirmation and do automatic redirect to the application when you include parameter post_logout_redirect_uri together with the parameter id_token_hint with the ID Token used for login."
They are both included in the url, but it still throws 404, probably searching for the confirmation page.

@adnsimona
Copy link
Author

adnsimona commented May 25, 2022

Also the custom theme / login inherits from keycloak theme, that inherits from base, so the deafult confirmation page should be there.

@mabartos mabartos added the area/authentication Indicates an issue on Authentication area label May 25, 2022
@adnsimona
Copy link
Author

Additional info: we upgraded from 14, and the new 18 version is from a legacy docker image, so we still use WildFly.

@adnsimona
Copy link
Author

adnsimona commented May 26, 2022

We discovered that the id_token_hint, that keycloak-js provides are not exactly the same as the token we got from the backend.
e.g. the "typ" is ID vs. Bearer, And the aud is different.
We also tried to replace the keycloak-js generated token to the Bearer in the url, but still getting the 404.

@adnsimona
Copy link
Author

adnsimona commented May 26, 2022

Also when the post_logout_redirect_uri was https://---oursite---.org/some_subpage, and we got 404, we replaced it with https://---oursite---.org in the url, and pressed enter, and it logged out correctly, and arrived on the login page.
But now we tried to send the redirectUri from frontend using keycloak-js set to https://---oursite---.org, that set the post_logout_redirect_uri to https://---oursite---.org, and we still get 404.

@adnsimona
Copy link
Author

Additional info: we use the same docker image with same setup locally and on the server.
Locally logout works correctly.
The only exception is that on the server we are setting the KEYCLOAK_FRONTEND_URL to https://---oursite---.org/auth/ (This worked so far)
and on the server the requests/responses are going through nginx. Maybe nginx not forwarding the full large url? I'm checking that next.

@adnsimona
Copy link
Author

adnsimona commented May 27, 2022

We found that the issue is the query limitation in IIS.
The logout url length with the query was 2800 chars.
This brings up an other idea though: Wouldn't it be nicer to make the logout a POST request and send the token_id_hint and the post_logout_redirect_uri in the body?

@hendisantika
Copy link

So, how do you fix the issue @adnsimona . I have some issue.
Thanks

@mposolda mposolda changed the title Keycloak 18 openid logout - 404 Keycloak 18 openid logout - 404 (due the 2800 characters limit in the HTTP query for the IIS server) Jul 29, 2022
@mposolda mposolda added help wanted area/adapter/javascript and removed status/triage area/authentication Indicates an issue on Authentication area labels Jul 29, 2022
@mposolda
Copy link
Contributor

mposolda commented Jul 29, 2022

@adnsimona Glad that you figured the issue. Sorry for the late response. Some alternative solution is (should surely work in Keycloak 19, not 100% sure if supported in Keycloak 18) that instead of using OIDC logout GET request, you can use POST request. This should help with the query limit. Using the POST request for the logout is currently not supported in the OIDC javascript adapter. I think it can be supported to add the flag option for the keycloak.js logout method to use the POST method for the logout instead of the GET method. So this would be purely task for the javascript adapter (nothing needed on the Keycloak server).

Considering this, I am moving this to the area/adapter/javascript and also I am adding label "Help wanted" as Keycloak team won't have time to look at this in the near future, so it would need to be a community contribution

@stianst stianst added kind/enhancement Categorizes a PR related to an enhancement and removed kind/bug Categorizes a PR related to a bug labels Oct 6, 2022
@mduzgun
Copy link

mduzgun commented Oct 11, 2022

It is related nginx configuration. nginx has character limitation in default configuration.
For fixing, we added this parameter in nginx conf:

proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

@jonkoops jonkoops self-assigned this May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants