Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 46071f3

Browse files
committed
[Security] made sure that we always replace the security access denied exception to an HTTP one
1 parent 7dc8901 commit 46071f3

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public function onKernelException(GetResponseForExceptionEvent $event)
9797
return;
9898
}
9999
} elseif ($exception instanceof AccessDeniedException) {
100+
$event->setException(new AccessDeniedHttpException($exception->getMessage(), $exception));
101+
100102
$token = $this->context->getToken();
101103
if (!$this->authenticationTrustResolver->isFullFledged($token)) {
102104
if (null !== $this->logger) {
@@ -129,8 +131,6 @@ public function onKernelException(GetResponseForExceptionEvent $event)
129131
$response = $event->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
130132
$response->setStatusCode(403);
131133
} else {
132-
$event->setException(new AccessDeniedHttpException($exception->getMessage(), $exception));
133-
134134
return;
135135
}
136136
} catch (\Exception $e) {
@@ -148,8 +148,6 @@ public function onKernelException(GetResponseForExceptionEvent $event)
148148
$this->logger->info(sprintf('Logout exception occurred; wrapping with AccessDeniedHttpException (%s)', $exception->getMessage()));
149149
}
150150

151-
$event->setException(new AccessDeniedHttpException($exception->getMessage(), $exception));
152-
153151
return;
154152
} else {
155153
return;

0 commit comments

Comments
 (0)