Skip to content

Commit 42ce187

Browse files
committed
feature #49193 [Security] Return 403 instead of 500 when no firewall 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 ------- c021ce79e8 [Security] Return 403 instead of 500 when no firewall is defined
2 parents 4756d09 + 2621e43 commit 42ce187

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Exception/AccessDeniedException.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111

1212
namespace Symfony\Component\Security\Core\Exception;
1313

14+
use Symfony\Component\HttpKernel\Attribute\WithHttpStatus;
15+
1416
/**
1517
* AccessDeniedException is thrown when the account has not the required role.
1618
*
1719
* @author Fabien Potencier <fabien@symfony.com>
1820
*/
21+
#[WithHttpStatus(403)]
1922
class AccessDeniedException extends RuntimeException
2023
{
2124
private array $attributes = [];

Exception/AuthenticationException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Core\Exception;
1313

14+
use Symfony\Component\HttpKernel\Attribute\WithHttpStatus;
1415
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1516

1617
/**
@@ -19,6 +20,7 @@
1920
* @author Fabien Potencier <fabien@symfony.com>
2021
* @author Alexander <iam.asm89@gmail.com>
2122
*/
23+
#[WithHttpStatus(401)]
2224
class AuthenticationException extends RuntimeException
2325
{
2426
/** @internal */

0 commit comments

Comments
 (0)