-
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
Use LaravelSessionStore in the SessionStateHandler. #135
Use LaravelSessionStore in the SessionStateHandler. #135
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some touch ups 👷
0454ebe
to
7ab8879
Compare
@nstapelbroek - Thank you for this! I have a few other changes that would require a major so let me find some time in an upcoming sprint to take a look at this. |
@joshcanhelp awesome! Let me know if there is anything I can do to help :) |
Any updates on this? Session is still broken with laravel |
@xaoseric - Apologies for the delay here. I'll take a look next week to see if we can do this without any breaking changes and, if not, start a branch for a new major. Thank you for your patience! |
Alright, so .... this PR looks great but definitely introduces breaking changes. We're working on a major in the PHP SDK that this plugin relies on, which will likely require some additional changes in this library. I'd like to hold off on releasing a major for this plugin before that one is done. I made a For this PR ... could we make the arguments in that constructor default to public function __construct(
array $auth0Config = null,
StoreInterface $sessionStorage = null,
SessionStateHandler $sessionStateHandler = null
)
{
if ( is_null( $auth0Config ) ) {
$auth0Config = config('laravel-auth0');
}
if ( is_null( $sessionStorage ) ) {
$sessionStorage = new LaravelSessionStore();
}
if ( is_null( $sessionStateHandler ) ) {
$sessionStateHandler = new SessionStateHandler($sessionStorage);
}
$auth0Config['store'] = $sessionStorage;
$auth0Config['state_handler'] = $sessionStateHandler;
$this->auth0 = new Auth0($auth0Config);
} All that said ... when I try out your branch locally, I get an invalid state error on login. Debugging a bit, I see that |
Hi @joshcanhelp, thank you for your feedback! If it's okay with you I would like to:
|
The invalid state errors happen outside of the login method you're using. In general, a state value is generated and stored in session by the SDK, that value is added to the link to login at Auth0, it's then added as a query parameter to the callback URL on successful login (again, regardless of method), and checked against the value stored before the redirect. When I tested, the
Would love to get this out in a minor, if possible, as we're at least a couple months away from a major here.
I don't think that would help much. That branch is no different from Thank you for sticking with this! I'll monitor this thread and provide feedback as needed 👍 |
Heya 👋 , a quick follow up on the authentication flow not working when using the LaravelSessionStorage. I managed to reproduce this on my local setup. My theory is that this happens because the I'll look into finding a fix in this package as this tends to be more of a framework specific problem. Thanks for responding and helping. I'll keep you posted! |
@nstapelbroek - Thank you for the update! Is there anything I can do to help this move along, like testing or explaining anything? I'd like to get this released along with the Laravel 6 update. |
@joshcanhelp As I'm slowly returning from holiday my time is becoming a bit more limited in the last couple of days, sorry about that. I'll make sure to solve the feedback in the PR before the end if the weekend. If you need it faster: feel free to make changes on the branch :) The challenge right now is that I'm not really happy with the solution that we have in the LaravelSessionStorage (persisting the cookie storage on write). It's a bit inexplicit and by working around the framework this PR causes more edge cases than it solves. My next try would be to find a way to simply extend the Auth0 class so I can override the Happy to hear your thoughts 😄 ! |
@nstapelbroek - I appreciate your work so far! So you're saying this is a problem with To be clear ... you're worried about the Happy to push a change for either one if it seems like a reasonable adjustment here. |
Good morning! 🎉 I just pushed out the requested changes. I also found a way to get this working without some of the inexplicit workarounds in this PR. Since those changes do break backwards compatibility I've submitted them in a separate PR in #140 so we can move forward here and talk about your valid raised concerns in a different PR. |
Also, by binding them both to your container you can extend or overwrite the behaviour a bit more easily. Which should help with testing or implemting different auth flows.
6e81f3d
to
6294950
Compare
@nstapelbroek - I did a bit of work on this and realized that we would have to make a few session-handling changes in #140 to make it work with this new method so I'm combining it all here. If this all makes sense then we can close #140. Using the method added in auth0/auth0-PHP#371, I switched the I also rebased the Laravel 6 addition and made the PHP SDK minimum If this looks good and works on your end, I'll merge the SDK PR, release it, approve this, and get everything released together. Again and again ... thank you for your work on this! |
@nstapelbroek - Sorry to bother you on this but I'd like to get this and the SDK released tomorrow. If you can take a look and make sure this looks good and works on your end, I'd appreciate it! @xaoseric - Can you pull this branch down and see if it solves your issue? |
Hey @joshcanhelp, Thanks for taking care! I'll do a quick test to confirm the PR in it's current state with a manual SDK of 5.6.0 works and then we can roll this out :) |
tested this on my local setup using the normal flow and a passwordless authentication. Works here! 👍 I did notice an invalid state error but I'm a bit convinced that this is caused by me clearing cookies and removing the Laravel storage in between requests. If I can help with anything else, let me know :) |
PHP SDK is released, this package to follow! |
👋
This is an implementation of the approach I pitched in #125 . Let me know what you think 😄
What has been done
a. I did this so I could re-use it when generating a paswordless
state
token without rebuilding what the SDK already offers for me with the callback handling :)b. In addition, by binding it on the
StoreInterface
you could now potentially overwrite the driver for this session storage 🎉Auth0Service
a. Since some dependencies are now bound to the app container. Why not pass them as params? :)
b. Having less logic in the constructor makes it a bit less error prone and more testable.
Notes
Auth0Service
which is public. So these changes are backwards incompatible and require a major version bump.References
#125
Testing
Can you help me with this? I was unable to find a testing setup. Any way to test this and proof that it works? I did remove some stuff that is unrelated to the issue just because my IDE hinted that it was dead code. 🤔
[x] This change has been tested on the latest version Laravel
Checklist
[x] I have read the Auth0 general contribution guidelines
[x] I have read the Auth0 Code of Conduct