-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
AccessDeniedException returns 500 instead of 403 when no firewall is defined. #34148
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
Comments
If I'm right, this is considered a "feature", not a "bug". But I'd like this behavior to be reconsidered. My reasoning is:
The only caveat is: if you throw 403 ... how can you know in |
I disagree here, a problem in your application is exactly what a 500 is for. |
@jvasseur yes ... but at the same time ... the application is working perfectly and the controller is being executed perfectly ... and you put the "you don't have access" exception perfectly ... so it may be debatable that a 403 should be returned. |
Some exceptions do have semantics related to HTTP codes. But any other exceptions don't have meaning. They're 500. Why would this specific exception be known by HttpKernel when it's in a foreign component? There are no reasons to me. A firewall is the bridge between both worlds. If there is no bridge, a 500 is legit. |
Then, let's close this as "won't fix/won't change". Thanks. |
There's still something illogical to me:
Here, everything looks like a 403, except the real return code 500 that is hidden in some network toolbar. There's something wrong. |
Thanks to new code infrastructure, we might be able to improve this. See #49193 |
…is defined (nicolas-grekas) This PR was merged into the 6.3 branch. Discussion ---------- [Security] Return 403 instead of 500 when no firewall is defined | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #34148 | License | MIT | Doc PR | - Looks like ranting on Twitter may pay of sometimes ;) https://twitter.com/zodman/status/1620954291187097600 The changes on ErrorListener make `#[WithHttpStatus]` and `#[WithLogLevel]` propagate to child classes. Best reviewed [ignoring white spaces](https://github.com/symfony/symfony/pull/49193/files?w=1). Commits ------- c021ce7 [Security] Return 403 instead of 500 when no firewall is defined
Symfony version(s) affected: 3.4.32
Description
When you throw a AccessDeniedException in a controller and no firewall is defined, a 500 error code is given instead of the expected 403.
How to reproduce
symfony new app
)throw new AccessDeniedException();
orthrow $this->createAccessDeniedException();
Expected
A 403 error should be raised.
Notes
I know there are similar issues but they all are closed without having been fixed - for what I've seen.
(#15236 #11663 #19906 #8467 #20233)
The text was updated successfully, but these errors were encountered: