Skip to content
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

Authorize Middleware returns 403 instead of 401 for unauthenticated users. #304

Closed
jeovajr opened this issue Sep 2, 2022 · 3 comments
Closed
Assignees

Comments

@jeovajr
Copy link

jeovajr commented Sep 2, 2022

SDK Version

7.0

PHP Version

PHP 8.1

Composer Version

2.x

What happened?

Auth0\Laravel\Http\Middleware\Stateless\Authorize Middleware returns 403 'Unauthorized' for unauthenticated users.

I can see how 403 should be returned when there's a defined scope and the user does not have authorization on that scope. But, when there is no authenticated user, the middleware sill returns 403, when it's usually expected to be 401.

Also, I'd expect 403 message to be 'Forbidden' instead of 'Unauthorized'.

401 => 'Unauthorized' => For unauthenticated user
403 => 'Forbidden' => For authenticated user with forbidden access to a specific scope.

How can we reproduce this issue?

Make a request to a route protected by auth0.authorize middleware without a valid token.
Response status code should be 401, but it will be 403.

Additional context

No response

@jeovajr jeovajr added the triage label Sep 2, 2022
@evansims
Copy link
Member

evansims commented Sep 6, 2022

Hey, @jeovajr 👋 Thanks for reporting this! Give me a bit to investigate this, but I think I agree with your conclusion there, that 403 makes more sense in that case.

@evansims
Copy link
Member

Hey again @jeovajr 👋 The SDK will be updated to reflect your suggestion in the forthcoming 7.2.0 release.

Thanks for your feedback and contribution!

@jeovajr
Copy link
Author

jeovajr commented Oct 12, 2022

@evansims thank you very much for this! I also noted that now we have native support for Laravel Cache APIs. That's also great. Thanks for that as well.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants