aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Security/Firewall/WsseListener.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Security/Firewall/WsseListener.php')
-rw-r--r--src/Wallabag/CoreBundle/Security/Firewall/WsseListener.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Security/Firewall/WsseListener.php b/src/Wallabag/CoreBundle/Security/Firewall/WsseListener.php
index 4d4f2145..d815d536 100644
--- a/src/Wallabag/CoreBundle/Security/Firewall/WsseListener.php
+++ b/src/Wallabag/CoreBundle/Security/Firewall/WsseListener.php
@@ -9,16 +9,19 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
9use Symfony\Component\Security\Core\SecurityContextInterface; 9use Symfony\Component\Security\Core\SecurityContextInterface;
10use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; 10use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
11use Wallabag\CoreBundle\Security\Authentication\Token\WsseUserToken; 11use Wallabag\CoreBundle\Security\Authentication\Token\WsseUserToken;
12use Symfony\Component\HttpKernel\Log\LoggerInterface;
12 13
13class WsseListener implements ListenerInterface 14class WsseListener implements ListenerInterface
14{ 15{
15 protected $securityContext; 16 protected $securityContext;
16 protected $authenticationManager; 17 protected $authenticationManager;
18 protected $logger;
17 19
18 public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager) 20 public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, LoggerInterface $logger)
19 { 21 {
20 $this->securityContext = $securityContext; 22 $this->securityContext = $securityContext;
21 $this->authenticationManager = $authenticationManager; 23 $this->authenticationManager = $authenticationManager;
24 $this->logger = $logger;
22 } 25 }
23 26
24 public function handle(GetResponseEvent $event) 27 public function handle(GetResponseEvent $event)
@@ -42,16 +45,21 @@ class WsseListener implements ListenerInterface
42 45
43 $this->securityContext->setToken($authToken); 46 $this->securityContext->setToken($authToken);
44 } catch (AuthenticationException $failed) { 47 } catch (AuthenticationException $failed) {
45 // ... you might log something here 48 $failedMessage = 'WSSE Login failed for '.$token->getUsername().'. Why ? '.$failed->getMessage();
46 49 $this->logger->err($failedMessage);
47 // To deny the authentication clear the token. This will redirect to the login page.
48 // $this->securityContext->setToken(null);
49 // return;
50 50
51 // Deny authentication with a '403 Forbidden' HTTP response 51 // Deny authentication with a '403 Forbidden' HTTP response
52 $response = new Response(); 52 $response = new Response();
53 $response->setStatusCode(403); 53 $response->setStatusCode(403);
54 $response->setContent($failedMessage);
54 $event->setResponse($response); 55 $event->setResponse($response);
56
57 return;
55 } 58 }
59
60 // By default deny authorization
61 $response = new Response();
62 $response->setStatusCode(403);
63 $event->setResponse($response);
56 } 64 }
57} 65}