File tree 4 files changed +37
-3
lines changed
src/Symfony/Component/Security
tests/Symfony/Tests/Component/Security/Http/Firewall
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 20
20
use Symfony \Component \Security \Core \Exception \AuthenticationException ;
21
21
use Symfony \Component \Security \Core \Exception \AccessDeniedException ;
22
22
use Symfony \Component \Security \Core \Exception \InsufficientAuthenticationException ;
23
+ use Symfony \Component \Security \Core \Exception \LogoutException ;
23
24
use Symfony \Component \Security \Http \HttpUtils ;
24
25
use Symfony \Component \HttpFoundation \Request ;
25
26
use Symfony \Component \HttpKernel \Log \LoggerInterface ;
@@ -140,6 +141,14 @@ public function onKernelException(GetResponseForExceptionEvent $event)
140
141
return ;
141
142
}
142
143
}
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 ;
143
152
} else {
144
153
return ;
145
154
}
Original file line number Diff line number Diff line change 16
16
use Symfony \Component \HttpFoundation \Response ;
17
17
use Symfony \Component \HttpKernel \Event \GetResponseEvent ;
18
18
use Symfony \Component \Security \Core \SecurityContextInterface ;
19
- use Symfony \Component \Security \Core \Exception \InvalidCsrfTokenException ;
19
+ use Symfony \Component \Security \Core \Exception \LogoutException ;
20
20
use Symfony \Component \Security \Http \HttpUtils ;
21
21
use Symfony \Component \Security \Http \Logout \LogoutHandlerInterface ;
22
22
use Symfony \Component \Security \Http \Logout \LogoutSuccessHandlerInterface ;
@@ -91,7 +91,7 @@ public function handle(GetResponseEvent $event)
91
91
$ csrfToken = $ request ->get ($ this ->options ['csrf_parameter ' ], null , true );
92
92
93
93
if (false === $ this ->csrfProvider ->isCsrfTokenValid ($ this ->options ['intention ' ], $ csrfToken )) {
94
- throw new InvalidCsrfTokenException ('Invalid CSRF token. ' );
94
+ throw new LogoutException ('Invalid CSRF token. ' );
95
95
}
96
96
}
97
97
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ public function testSuccessHandlerReturnsNonResponse()
145
145
}
146
146
147
147
/**
148
- * @expectedException Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException
148
+ * @expectedException Symfony\Component\Security\Core\Exception\LogoutException
149
149
*/
150
150
public function testCsrfValidationFails ()
151
151
{
You can’t perform that action at this time.
0 commit comments