-
Notifications
You must be signed in to change notification settings - Fork 142
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
Question: mitigate checks.state argument is missing
error when messing with concurrent login.
#467
Comments
checks.state argument is missing
error when messing with concurrent tabs.checks.state argument is missing
error when messing with concurrent tabs.
checks.state argument is missing
error when messing with concurrent tabs.checks.state argument is missing
error when messing with concurrent login.
Hi @maxime-bc - thanks for raising this This is expected behaviour - you drop a state cookie when you login and check it when you return to your app. If you open a new tab and start a 2nd login, you overwrite the state cookie on the first tab - so if you finish login on this tab it will fail since the state cookie is stale. You should catch the error and prompt the user to login again (which should not require interaction, since the AS will have a session) The error is not great, but we plan to make better more granular errors in the next major |
Hi, thanks for your answer.
If I understood you well, in my error handler, I should redirect the user to the |
Hi @maxime-bc I would prompt the user rather than automatically redirect (a message to say "try again" and a login button). You may get a 400 that the user can't recover from by logging in again, then you would get into an infinite loop. |
When you say prompt the user to log in again, should the server send back something like this instead of the redirect? res.send('<p>A login error occurred. Please try to login again.</p><a href="/login">Log In</a>'); |
Yep, exactly - however you would do something like this in your UI |
So, server-side, when a |
Yeah - that would work 👍 |
Ok, thanks for your answers! It's clearer for me now. In this issue, I took the
So, in this case, how could I handle a I could create a route in my Vue.js app router, say |
Hi @maxime-bc
If you put the |
Hi @adamjmcgrath, I could do this but I'm not generating views server-side, so when an error occurs I would like to let my SPA handle the error and display a nice error message to the user. What I wanted to do: Server-side, I redirect to But that won't work since the Only solution I see: As you said, put a |
@maxime-bc - If you have a server side app (even if it is serving a spa), you still need to handle and display server side errors. How you decide to do that is up to the you, the application author, and not something that this SDK can help with. |
Yes, I understand. Thanks for taking time to answer me. |
Problem description and reproduction steps
I am currently using the
01-Login
sample from theauth0-express-webapp-sample
repository to connect via OpenID to a Keycloak 21.1.0 server, and it is working fine.In
server.js
, I only updated the config object so that the sample works with my Keycloak server, as follows :In Keycloak, I have set up a realm named
dummy
, and in this realm, I have created a client nameddummyclient
.I kept the configuration bare minimum and only followed the "Create client" form : I set the "Client authentication" switch to "On" as I want my client private and then set all the URLs.
But when I run the following steps, I get a
💣 400: checks.state argument is missing
error :1 - Open two tabs and try to access the protected
/profile
route. As we are not logged in, we are redirected to the Keycloak login page in both tabs.2 - Log in in the second tab: we are redirected to the
/profile
page.3 - Refresh the first tab where we are still not logged in and the error appears. If instead of refreshing the page you fill out the login form, Keycloak will tell you "You are already logged in." and display a "« Back to Application" link. Clicking it does not raise an error.
I also just found out that in step 2, if you log in from the first tab instead of the second, the following error is raised:
💣 400: invalid_grant (PKCE verification failed)
.How can I mitigate these errors? I observed the same behaviour when I was using
passport
+openid-client
.To not affect the user with this error, I have updated the sample error handler as follows:
It seems to do the job, but I'm wondering if there is any cleaner way of handling this?
Thanks for any help!
Environment
auth0-express-webapp-sample
(with[email protected]
),The text was updated successfully, but these errors were encountered: