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

[Bug]: AuthenticationException: Laravels authentication exception doesn't set it's status code to 401, resulting in laravel-api-problem defaulting it to 500. #6

Open
JeremyM1985 opened this issue Aug 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@JeremyM1985
Copy link

What happened?

For what ever reason Laravel's AuthenticationException does not set the exception status code to 401 (defaults 0).

Only when the exception is handled in vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:716 does it grab the get the exception message and return 401 via json response.

laravel-api-problem intercepts the AuthenticationException and the getStatusCode method only sees status code 0, resulting in 500 error for authentication exception.

Expected result would be 401 regardless of status code 0 for an AuthenticationException.

How to reproduce the bug

Use fortify, navigate to an an endpoint that requires authentication will being unauthenticated.

Package Version

Laravel 11

PHP Version

0.03

Laravel Version

11

Which operating systems does with happen with?

Windows

Notes

No response

@JeremyM1985 JeremyM1985 added the bug Something isn't working label Aug 17, 2024
@JeremyM1985
Copy link
Author

Just wanted to add that AuthorizationException deliberately adds status code 0 which would also throw 500 internal server error instead of expected 403.

Didn't check other exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant