-
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
Incorrect middleware ordering #414
Comments
I suspect this might be related to a bug I just pushed a fix for, #415. You should not be pre-pending or prioritizing that middleware, it isn't necessary. Beyond that, are you issuing the GET request using an Under intended circumstances, the AuthorizationGuard will never run from |
Hey @marijnvanderhorst, could you please try the new 7.9.1 release and check if that resolves the issue for you? I suspect it should address the problem. |
I am experiencing an issue that I suspect is also related to this. I have a laravel project using https://github.com/inertiajs/inertia-laravel/ With auth0 installed, inertia's HandleInertiaRequests middleware This also means that my application's Laravel Nova package is broken as it is built on Inertia. Note that I am able to access the logged in user via |
@squpshift That doesn't sound related to the reported issue here, but I'll be happy to look into it separately. (Perhaps you meant to reply to #412?) |
It seemed to be an issue of middleware order to me, I'm happy to open a separate issue though. I'm having the issue without telescope installed, so not related to #412. |
Unfortunately, it still doesn't work. I'm getting a 401 Unauthorized now, even though I'm sending a valid token. This, as when I change the It seems to be using Laravel's Were you not able to reproduce the issue using the steps that I provided in the description? |
I also have this issue. Likewise: if I change the auth.defaults.guard value manually to auth0-api, it does work as expected. |
Changing the auth.defaults.guard did not resolve my version of this issue, but @marijnvanderhorst's suggestion did, which I have included in PR #419 |
Thank you all for your help in troubleshooting this issue. I have a fix merged, and will ship a new release ASAP that includes it. |
Checklist
docs
directory and have not found a solution.Laravel Version
10
SDK Version
7.8
PHP Version
PHP 8.2
Description
Assume we have an API-only application. Hence, we only need to authorize requests. No authentication has to be performed whatsoever.
From the sample repository, it is clear that with the latest version of this SDK we should be able to use the
auth
middleware that is provided by the Laravel framework for authorization of API requests. For this, we should only have to define the routes in theroutes/api.php
file and include said middleware in the route.With the latest version of the SDK, this does not seem to work since the
AuthorizerMiddleware
has a lower priority than theauth
middleware. Hence, the auth guard is only set to the API version after the Laravel framework tries (and fails) to authenticate the request using the defaultAuthenticationGuard
.How can we reproduce this issue?
composer create-project auth0-samples/laravel auth0-laravel-quickstart
..env
file based on the provided.env.example
.php artisan key:generate
..env
file. Note that we don't set any client ID and secret since we will only need to authorize requests, no authentication is required./api/private
endpoint.vendor/auth0/login/src/Guards/AuthenticationGuard.php
. I strongly believe the authentication guard should not be used for API requests, rather I would expect the Authorization Guard to be used instead.boot()
method of theapp/Providers/AppServiceProvider.php
./api/private
endpoint again (with appropriate Bearer token).Your token is valid; you are authorized.
.IMO, this shows that the middleware priority is indeed incorrectly configured within the SDK. This, as ensuring that the
AuthorizerMiddleware
is executed before theauth
middleware resolves the issue immediately. IMO the SDK should take care of this.The text was updated successfully, but these errors were encountered: