-
Notifications
You must be signed in to change notification settings - Fork 136
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
Setting of state_handler in Auth0Service causes "Invalid state" error #154
Comments
@iAmRoland - Apologies for the delay in getting back to you. We have a few reports of state handling issues in this library, possibly because of the previous release, but I have not been able to reproduce anything so far. We're adjusting how state is handled and stored in the SDK in an upcoming major release but happy to do a patch release if we figure out that the source of this issue is indeed in the SDK or this package. I would say that Lock.js will complicate things and, in general, we recommend using Universal Login (hosted page) rather than the embedded one. So, the 5.3.0 was meant to address and fix issues with state handling, mainly due to misuse of the Laravel session handing. Commenting the line out you mentioned will default the SDK to use "regular" session handling for state, which will work for many cases but not all. In short, state is:
... so if you're checking what's getting sent and what's stored, you'll want to:
Auth0 Application and Connection settings on the dashboard won't have any effect on state checking, it's all handled in the application code itself. |
I'm encountering similar issues when I've dug through some code and believe its related to this pull request. #135 If I manually set the constructor in I've been unsuccessful in using the Laravel IoC to construct The root of the issue appears to be here.
Apologies if this isn't clear. I'll try and clarify further if you have questions. |
@mraypold - Appreciate the detailed report here. You're correct about the instance checking here, that should be But, more critically, we went from accepting a This definitely needs a patch release. Can you take a look at the diff below and see if this addresses your situation, both the config file and the IoC? My local tests are working. https://github.com/auth0/laravel-auth0/compare/fix-store-and-state-handing
If the logic makes sense, I'll get tests in there and submit a PR. @nstapelbroek - Would you take a look here and make sure this still solves your use case as well? |
@joshcanhelp I've taken a look at the branch and tested it against our local environments. It appears to have solved the issues we are encountering. We're currently running a temporary fork with very similar code changes, but your solution looks a bit cleaner. My only comment would be that I think the |
@mraypold - Thanks for the quick look here. You're correct about the null coalescing ... I didn't run any PHP compatibility scans yet. |
Tested the changes as well, seems to fix the issue on my end 👍 |
Hey everyone, Thanks for notifying me. I completely missed this issue in the last couple of days. The suggested fix in #156 seems good and works on my local setup. 👍 edit: Typos 🤓 |
@nstapelbroek - Appreciate the testing and response! @iAmRoland @mraypold - One thing that would be helpful to know is why you are skipping state checking in your application. I still plan on releasing this patch but disabling state may not be possible in an upcoming major. |
@joshcanhelp One of our clients requires IdP initiated SSO which required the state_handler to be disabled for this one workflow. In all other cases it was possible to use state handling as recomended by Auth0. |
#156 is ready for final review. Our team will look at it this morning and get a release out today 👍 Thanks for the assistance here everyone |
Awesome! I disabled state handling when I implemented Lock.js, this was about a year or two ago though. Have not had the time to go through and possibly revamp it, only upgrades and patches mostly. |
@iAmRoland Can you describe how you disabled state handling? I am having the same issue I think... even on the newer releases. I am also using Lock.js. If @joshcanhelp has any suggestions regarding this same error still happening on 5.3.1 (I've tried a few other updates as well, and always get the same error). I'm trying to update a Laravel app to version 6 (and my next task is to update it to v7). Thanks! |
@joshcanhelp I think this issue should be reopened. I'm trying to upgrade from We are using |
@joshcanhelp I think I found a workaround but not sure if it's safe or recommended. In my Controller that loads our Blade file with the login view containing the auth0 lock script, I am registering a state via I have 2 reservations about the workaround:
So if either of these reasons means we shouldn't be doing things this way, can you please respond? Thank you and have a nice day! |
@joshcanhelp though I did just find this: #102 - sorry for all the posts. Maybe they will be helpful to somebody else. I think auth0 should consider adding something about this in the docs. |
@bryanjamesmiller - Apologies for the delay in getting back to you here. The fix here is fixing a specific case where the I would highly recommend using the latest version of this package, 6.0.0, which will pull in the latest version of the underlying SDK and hopefully help with this issue. The version you're using above is, as you mentioned, using deprecated and now removed components. If you're still having this issue with the latest version, please open a new Issue with the details of your setup 👍 |
Description
Upgraded from 5.2.0 to 5.3.0 and ran into this issue.
When I attempt to login I get a "Invalid state" error. Went through multiple threads and couple issues here and on other repos without success.
After some time of debugging I found the following line to be a issue:
laravel-auth0/src/Auth0/Login/Auth0Service.php
Line 55 in a008725
Commenting it out made the login work again, but editing vendor files is no fix.
Attempted to find out why. Went into the SDK and dumped out the state, the store does not seem to contain anything. The
state
variable does never seem to get set. So the validate method returns false all the time. Maybe i'm incorrectly understanding how this should work.Also is it supposed to set the state handler even if I have
state_handler
set tofalse
in my config?Or is that config meant only for the SDK?
Reproduction
This might be specific to something in my project, a bit unsure still.
I'm using the database connection in Auth0, logging in with username and password.
My setup looks pretty much like this guide, with custom user handling:
https://auth0.com/docs/quickstart/webapp/laravel#integrate-auth0-in-your-application
Only differences are the login and logout methods.
On login i'm simply checking if user is logged in and then returning a login view if they're not. On that view I have Lock.js setup and configured.
Maybe a relevant section from that configuration:
Environment
The text was updated successfully, but these errors were encountered: