File tree Expand file tree Collapse file tree 4 files changed +37
-3
lines changed
src/Symfony/Component/Security
tests/Symfony/Tests/Component/Security/Http/Firewall Expand file tree Collapse file tree 4 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of the Symfony package.
5+ *
6+ * (c) Fabien Potencier <fabien@symfony.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Symfony \Component \Security \Core \Exception ;
13+
14+ /**
15+ * LogoutException is thrown when the account cannot be logged out.
16+ *
17+ * @author Jeremy Mikola <jmikola@gmail.com>
18+ */
19+ class LogoutException extends \RuntimeException
20+ {
21+ public function __construct ($ message = 'Logout Exception ' , \Exception $ previous = null )
22+ {
23+ parent ::__construct ($ message , 403 , $ previous );
24+ }
25+ }
Original file line number Diff line number Diff line change 2020use Symfony \Component \Security \Core \Exception \AuthenticationException ;
2121use Symfony \Component \Security \Core \Exception \AccessDeniedException ;
2222use Symfony \Component \Security \Core \Exception \InsufficientAuthenticationException ;
23+ use Symfony \Component \Security \Core \Exception \LogoutException ;
2324use Symfony \Component \Security \Http \HttpUtils ;
2425use Symfony \Component \HttpFoundation \Request ;
2526use Symfony \Component \HttpKernel \Log \LoggerInterface ;
@@ -140,6 +141,14 @@ public function onKernelException(GetResponseForExceptionEvent $event)
140141 return ;
141142 }
142143 }
144+ } elseif ($ exception instanceof LogoutException) {
145+ if (null !== $ this ->logger ) {
146+ $ this ->logger ->info (sprintf ('Logout exception occurred; wrapping with AccessDeniedHttpException (%s) ' , $ exception ->getMessage ()));
147+ }
148+
149+ $ event ->setException (new AccessDeniedHttpException ($ exception ->getMessage (), $ exception ));
150+
151+ return ;
143152 } else {
144153 return ;
145154 }
Original file line number Diff line number Diff line change 1616use Symfony \Component \HttpFoundation \Response ;
1717use Symfony \Component \HttpKern
E54B
el \Event \GetResponseEvent ;
1818use Symfony \Component \Security \Core \SecurityContextInterface ;
19- use Symfony \Component \Security \Core \Exception \InvalidCsrfTokenException ;
19+ use Symfony \Component \Security \Core \Exception \LogoutException ;
2020use Symfony \Component \Security \Http \HttpUtils ;
2121use Symfony \Component \Security \Http \Logout \LogoutHandlerInterface ;
2222use Symfony \Component \Security \Http \Logout \LogoutSuccessHandlerInterface ;
@@ -91,7 +91,7 @@ public function handle(GetResponseEvent $event)
9191 $ csrfToken = $ request ->get ($ this ->options ['csrf_parameter ' ], null , true );
9292
9393 if (false === $ this ->csrfProvider ->isCsrfTokenValid ($ this ->options ['intention ' ], $ csrfToken )) {
94- throw new InvalidCsrfTokenException ('Invalid CSRF token. ' );
94+ throw new LogoutException ('Invalid CSRF token. ' );
9595 }
9696 }
9797
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ public function testSuccessHandlerReturnsNonResponse()
145145 }
146146
147147 /**
148- * @expectedException Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException
148+ * @expectedException Symfony\Component\Security\Core\Exception\LogoutException
149149 */
150150 public function testCsrfValidationFails ()
151151 {
You can’t perform that action at this time.
0 commit comments