Closed Qnouro closed 1 week ago
Hi, I believe that in this specific case the issue is caused because the user has two tabs open: one with shinyproxy and any other page that is using keycloak for SSO. Because the session expires during the night, the user signs in one tab, then goes to shinyproxy and signs-in again. This will cause the already_logged_in
in the keycloak logs.
I looked at the keycloak release notes and it seem there is now a specific error we can catch in ShinyProxy: https://www.keycloak.org/docs/latest/release_notes/index.html#addressed-you-are-already-logged-in-for-expired-authentication-sessions
We will look into this for the next release and try to implement a fix.
In the meanwhile, you could implement the redirect in the auth-error.html
template (https://github.com/openanalytics/containerproxy/blob/master/src/main/resources/templates/auth-error.html), e.g. using:
<script>
window.location.href = "/";
</script>
Hello,
Thank you for your reply. The issue occurs even if shinyproxy is the only app using keycloak and directly after rebooting the computer (so no other tab open). There may be more to dig here, though the simplest and most straight-forward approach is obviously to catch the already_logged_in
error.
We have implemented the suggested template override as a temporary fix. Looking forward to the next release !
Thanks again for your help, Cheers
Hello,
Context
We have a shinyproxy instance running alongside a keycloak instance. Sometimes (not always), when a user connects (successfully), it gets redirected to the /auth_error page. Refreshing or clicking on "Go back to the main page" redirects them to the shinyproxy homepage.
We aren't certain but we suspect that we may have a redirect loop as referred to in the documentation: https://www.shinyproxy.io/documentation/troubleshooting/#my-browser-reports-a-redirect-loop-when-using-openid-connect.
Shinyproxy version: 3.1.1 (we had the same issue in 3.1.0)
Logs:
Keycloak log:
Shinyproxy log:
How to reproduce
The error is hard to reproduce and, in the same conditions, doesn't always happen.
It however seems to happen in the following scenario:
User has been logged in the and using an app hosted on shinyproxy
Day is over and the user hasn't explicitely clicked on "logout". Browser gets closed + PC shut down
The following day the user logs into my_app.com
The user is redirected to the login page and they enter their credentials
They get redirected to the /auth_error page.
Please note that when clicking on "Go back to the main page", the user is redirected to the homepage and is effectively already logged in. We can also see in the shinyproxy logs that the user has been logged in before the error is raised (instantly afterwards).
Potential tracks
Some tracks we have:
The token lifespans are mismatched between the configurations of keycloak and shinyproxy:
We couldn't detect anything wrong with the tokens
We had this problem with and without redis so it doesn't seem related to that either.
We have considered implementing an NGinx server (as it was done here: https://github.com/openanalytics/shinyproxy/issues/166) to handle the "already_logged_in" and throw a 200 OK instead of an error (since there is no problem in the authentication flow).
Configurations
Shinyproxy
applications.yml:
Keycloak
Keycloak realm settings that may be related/interesting:
Access settings:
Sessions:
Tokens:
Thank you in advance for your help and time!
Nour