Skip to content

Setting of state_handler in Auth0Service causes "Invalid state" error #154

@iAmRoland

Description

@iAmRoland

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:

$auth0Config['state_handler'] = $sessionStateHandler;

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 to false 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:

auth: {
    redirectUrl: '{{ $auth0Config["redirect_uri"] }}',
    responseType: 'code',
    params: {
        scope: 'openid profile name email'
    }
}

Environment

  • Version of this library used: 5.3.0
  • Version of the platform or framework used, if applicable: Laravel 5.8 and PHP 7.2
  • Other modules/plugins/libraries that might be involved: Using the latest SDK

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions