Skip to content

Commit 2621e43

Browse files
[Security] Return 403 instead of 500 when no firewall is defined
1 parent c438bee commit 2621e43

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 <[email protected]>
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 <[email protected]>
2021
* @author Alexander <[email protected]>
2122
*/
23+
#[WithHttpStatus(401)]
2224
class AuthenticationException extends RuntimeException
2325
{
2426
/** @internal */

0 commit comments

Comments
 (0)