@@ -12,7 +12,6 @@ |
||
| 12 | 12 | namespace Gesdinet\JWTRefreshTokenBundle\EventListener; |
| 13 | 13 | |
| 14 | 14 | use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface; |
| 15 | -use Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken; |
|
| 16 | 15 | use Lexik\Bundle\JWTAuthenticationBundle\Event\AuthenticationSuccessEvent; |
| 17 | 16 | use Symfony\Component\Security\Core\User\UserInterface; |
| 18 | 17 | use Symfony\Component\Validator\Validator\ValidatorInterface; |
@@ -19,9 +19,17 @@ |
||
| 19 | 19 | $this->token = $token; |
| 20 | 20 | $this->response = $response; |
| 21 | 21 | } |
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * @return string|null |
|
| 25 | + */ |
|
| 22 | 26 | public function getToken(){ |
| 23 | 27 | return $this->token; |
| 24 | 28 | } |
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @return string|null |
|
| 32 | + */ |
|
| 25 | 33 | public function getResponse(){ |
| 26 | 34 | return $this->response; |
| 27 | 35 | } |
@@ -14,21 +14,21 @@ |
||
| 14 | 14 | use Symfony\Component\EventDispatcher\Event; |
| 15 | 15 | |
| 16 | 16 | class AddTokenResponseEvent extends Event { |
| 17 | - private $data = []; |
|
| 18 | - public function __construct($token, Response $response){ |
|
| 19 | - $this->token = $token; |
|
| 20 | - $this->response = $response; |
|
| 21 | - } |
|
| 22 | - public function getToken(){ |
|
| 23 | - return $this->token; |
|
| 24 | - } |
|
| 25 | - public function getResponse(){ |
|
| 26 | - return $this->response; |
|
| 27 | - } |
|
| 28 | - public function setData(array $data){ |
|
| 29 | - $this->data = $data; |
|
| 30 | - } |
|
| 31 | - public function getData(){ |
|
| 32 | - return $this->data; |
|
| 33 | - } |
|
| 17 | + private $data = []; |
|
| 18 | + public function __construct($token, Response $response){ |
|
| 19 | + $this->token = $token; |
|
| 20 | + $this->response = $response; |
|
| 21 | + } |
|
| 22 | + public function getToken(){ |
|
| 23 | + return $this->token; |
|
| 24 | + } |
|
| 25 | + public function getResponse(){ |
|
| 26 | + return $this->response; |
|
| 27 | + } |
|
| 28 | + public function setData(array $data){ |
|
| 29 | + $this->data = $data; |
|
| 30 | + } |
|
| 31 | + public function getData(){ |
|
| 32 | + return $this->data; |
|
| 33 | + } |
|
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -15,20 +15,20 @@ |
||
| 15 | 15 | |
| 16 | 16 | class AddTokenResponseEvent extends Event { |
| 17 | 17 | private $data = []; |
| 18 | - public function __construct($token, Response $response){ |
|
| 18 | + public function __construct($token, Response $response) { |
|
| 19 | 19 | $this->token = $token; |
| 20 | 20 | $this->response = $response; |
| 21 | 21 | } |
| 22 | - public function getToken(){ |
|
| 22 | + public function getToken() { |
|
| 23 | 23 | return $this->token; |
| 24 | 24 | } |
| 25 | - public function getResponse(){ |
|
| 25 | + public function getResponse() { |
|
| 26 | 26 | return $this->response; |
| 27 | 27 | } |
| 28 | - public function setData(array $data){ |
|
| 28 | + public function setData(array $data) { |
|
| 29 | 29 | $this->data = $data; |
| 30 | 30 | } |
| 31 | - public function getData(){ |
|
| 31 | + public function getData() { |
|
| 32 | 32 | return $this->data; |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -13,17 +13,17 @@ |
||
| 13 | 13 | use Gesdinet\JWTRefreshTokenBundle\Event\GetTokenRequestEvent; |
| 14 | 14 | |
| 15 | 15 | class RequestHeaderTokenExtractorEventListener { |
| 16 | - private $name; |
|
| 17 | - public function __construct($name){ |
|
| 18 | - $this->name = $name; |
|
| 19 | - } |
|
| 20 | - public function onGetToken(GetTokenRequestEvent $event){ |
|
| 21 | - $request = $event->getRequest(); |
|
| 22 | - $refreshTokenString = $request->headers->get($this->name); |
|
| 16 | + private $name; |
|
| 17 | + public function __construct($name){ |
|
| 18 | + $this->name = $name; |
|
| 19 | + } |
|
| 20 | + public function onGetToken(GetTokenRequestEvent $event){ |
|
| 21 | + $request = $event->getRequest(); |
|
| 22 | + $refreshTokenString = $request->headers->get($this->name); |
|
| 23 | 23 | |
| 24 | - if($refreshTokenString){ |
|
| 24 | + if($refreshTokenString){ |
|
| 25 | 25 | $event->setToken($refreshTokenString); |
| 26 | 26 | $event->stopPropagation(); |
| 27 | 27 | } |
| 28 | - } |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | |
| 15 | 15 | class RequestHeaderTokenExtractorEventListener { |
| 16 | 16 | private $name; |
| 17 | - public function __construct($name){ |
|
| 17 | + public function __construct($name) { |
|
| 18 | 18 | $this->name = $name; |
| 19 | 19 | } |
| 20 | - public function onGetToken(GetTokenRequestEvent $event){ |
|
| 20 | + public function onGetToken(GetTokenRequestEvent $event) { |
|
| 21 | 21 | $request = $event->getRequest(); |
| 22 | 22 | $refreshTokenString = $request->headers->get($this->name); |
| 23 | 23 | |
| 24 | - if($refreshTokenString){ |
|
| 24 | + if ($refreshTokenString) { |
|
| 25 | 25 | $event->setToken($refreshTokenString); |
| 26 | 26 | $event->stopPropagation(); |
| 27 | 27 | } |
@@ -14,17 +14,17 @@ |
||
| 14 | 14 | use Gesdinet\JWTRefreshTokenBundle\Event\GetTokenRequestEvent; |
| 15 | 15 | |
| 16 | 16 | class RequestCookieTokenExtractorEventListener { |
| 17 | - private $name; |
|
| 18 | - public function __construct($name){ |
|
| 19 | - $this->name = $name; |
|
| 20 | - } |
|
| 21 | - public function onGetToken(GetTokenRequestEvent $event){ |
|
| 22 | - $request = $event->getRequest(); |
|
| 23 | - $refreshTokenString = $request->cookies->get($this->name); |
|
| 17 | + private $name; |
|
| 18 | + public function __construct($name){ |
|
| 19 | + $this->name = $name; |
|
| 20 | + } |
|
| 21 | + public function onGetToken(GetTokenRequestEvent $event){ |
|
| 22 | + $request = $event->getRequest(); |
|
| 23 | + $refreshTokenString = $request->cookies->get($this->name); |
|
| 24 | 24 | |
| 25 | - if($refreshTokenString){ |
|
| 25 | + if($refreshTokenString){ |
|
| 26 | 26 | $event->setToken($refreshTokenString); |
| 27 | 27 | $event->stopPropagation(); |
| 28 | 28 | } |
| 29 | - } |
|
| 29 | + } |
|
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -15,14 +15,14 @@ |
||
| 15 | 15 | |
| 16 | 16 | class RequestCookieTokenExtractorEventListener { |
| 17 | 17 | private $name; |
| 18 | - public function __construct($name){ |
|
| 18 | + public function __construct($name) { |
|
| 19 | 19 | $this->name = $name; |
| 20 | 20 | } |
| 21 | - public function onGetToken(GetTokenRequestEvent $event){ |
|
| 21 | + public function onGetToken(GetTokenRequestEvent $event) { |
|
| 22 | 22 | $request = $event->getRequest(); |
| 23 | 23 | $refreshTokenString = $request->cookies->get($this->name); |
| 24 | 24 | |
| 25 | - if($refreshTokenString){ |
|
| 25 | + if ($refreshTokenString) { |
|
| 26 | 26 | $event->setToken($refreshTokenString); |
| 27 | 27 | $event->stopPropagation(); |
| 28 | 28 | } |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | use Gesdinet\JWTRefreshTokenBundle\Event\GetTokenRequestEvent; |
| 14 | 14 | |
| 15 | 15 | class RequestBodyTokenExtractorEventListener { |
| 16 | - private $name; |
|
| 16 | + private $name; |
|
| 17 | 17 | public function __construct($name){ |
| 18 | - $this->name = $name; |
|
| 19 | - } |
|
| 20 | - public function onGetToken(GetTokenRequestEvent $event){ |
|
| 21 | - $request = $event->getRequest(); |
|
| 22 | - $refreshTokenString = null; |
|
| 18 | + $this->name = $name; |
|
| 19 | + } |
|
| 20 | + public function onGetToken(GetTokenRequestEvent $event){ |
|
| 21 | + $request = $event->getRequest(); |
|
| 22 | + $refreshTokenString = null; |
|
| 23 | 23 | if ($request->headers->get('content_type') == 'application/json') { |
| 24 | 24 | $content = $request->getContent(); |
| 25 | 25 | $params = !empty($content) ? json_decode($content, true) : array(); |
@@ -34,5 +34,5 @@ discard block |
||
| 34 | 34 | $event->setToken($refreshTokenString); |
| 35 | 35 | $event->stopPropagation(); |
| 36 | 36 | } |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -14,10 +14,10 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | class RequestBodyTokenExtractorEventListener { |
| 16 | 16 | private $name; |
| 17 | - public function __construct($name){ |
|
| 17 | + public function __construct($name) { |
|
| 18 | 18 | $this->name = $name; |
| 19 | 19 | } |
| 20 | - public function onGetToken(GetTokenRequestEvent $event){ |
|
| 20 | + public function onGetToken(GetTokenRequestEvent $event) { |
|
| 21 | 21 | $request = $event->getRequest(); |
| 22 | 22 | $refreshTokenString = null; |
| 23 | 23 | if ($request->headers->get('content_type') == 'application/json') { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $refreshTokenString = $request->request->get($this->name); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if($refreshTokenString){ |
|
| 33 | + if ($refreshTokenString) { |
|
| 34 | 34 | $event->setToken($refreshTokenString); |
| 35 | 35 | $event->stopPropagation(); |
| 36 | 36 | } |
@@ -14,13 +14,13 @@ |
||
| 14 | 14 | use Gesdinet\JWTRefreshTokenBundle\Event\AddTokenResponseEvent; |
| 15 | 15 | |
| 16 | 16 | class ResponseHeaderTokenSetterEventListener { |
| 17 | - private $name; |
|
| 18 | - public function __construct($name){ |
|
| 19 | - $this->name = $name; |
|
| 20 | - } |
|
| 21 | - public function onAddToken(AddTokenResponseEvent $event){ |
|
| 22 | - $response = $event->getResponse(); |
|
| 23 | - $token = $event->getToken(); |
|
| 24 | - $response->headers->set($this->name, $token); |
|
| 25 | - } |
|
| 17 | + private $name; |
|
| 18 | + public function __construct($name){ |
|
| 19 | + $this->name = $name; |
|
| 20 | + } |
|
| 21 | + public function onAddToken(AddTokenResponseEvent $event){ |
|
| 22 | + $response = $event->getResponse(); |
|
| 23 | + $token = $event->getToken(); |
|
| 24 | + $response->headers->set($this->name, $token); |
|
| 25 | + } |
|
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |
@@ -15,10 +15,10 @@ |
||
| 15 | 15 | |
| 16 | 16 | class ResponseHeaderTokenSetterEventListener { |
| 17 | 17 | private $name; |
| 18 | - public function __construct($name){ |
|
| 18 | + public function __construct($name) { |
|
| 19 | 19 | $this->name = $name; |
| 20 | 20 | } |
| 21 | - public function onAddToken(AddTokenResponseEvent $event){ |
|
| 21 | + public function onAddToken(AddTokenResponseEvent $event) { |
|
| 22 | 22 | $response = $event->getResponse(); |
| 23 | 23 | $token = $event->getToken(); |
| 24 | 24 | $response->headers->set($this->name, $token); |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | use Gesdinet\JWTRefreshTokenBundle\Event\AddTokenResponseEvent; |
| 15 | 15 | |
| 16 | 16 | class ResponseBodyTokenSetterEventListener { |
| 17 | - private $name; |
|
| 18 | - public function __construct($name){ |
|
| 19 | - $this->name = $name; |
|
| 20 | - } |
|
| 21 | - public function onAddToken(AddTokenResponseEvent $event){ |
|
| 22 | - $token = $event->getToken(); |
|
| 23 | - $data = $event->getData(); |
|
| 24 | - $data[$this->name] = $token; |
|
| 25 | - $event->setData($data); |
|
| 26 | - } |
|
| 17 | + private $name; |
|
| 18 | + public function __construct($name){ |
|
| 19 | + $this->name = $name; |
|
| 20 | + } |
|
| 21 | + public function onAddToken(AddTokenResponseEvent $event){ |
|
| 22 | + $token = $event->getToken(); |
|
| 23 | + $data = $event->getData(); |
|
| 24 | + $data[$this->name] = $token; |
|
| 25 | + $event->setData($data); |
|
| 26 | + } |
|
| 27 | 27 | } |
| 28 | 28 | \ No newline at end of file |
@@ -15,10 +15,10 @@ |
||
| 15 | 15 | |
| 16 | 16 | class ResponseBodyTokenSetterEventListener { |
| 17 | 17 | private $name; |
| 18 | - public function __construct($name){ |
|
| 18 | + public function __construct($name) { |
|
| 19 | 19 | $this->name = $name; |
| 20 | 20 | } |
| 21 | - public function onAddToken(AddTokenResponseEvent $event){ |
|
| 21 | + public function onAddToken(AddTokenResponseEvent $event) { |
|
| 22 | 22 | $token = $event->getToken(); |
| 23 | 23 | $data = $event->getData(); |
| 24 | 24 | $data[$this->name] = $token; |
@@ -15,15 +15,15 @@ |
||
| 15 | 15 | use Symfony\Component\HttpFoundation\Cookie; |
| 16 | 16 | |
| 17 | 17 | class ResponseCookieTokenSetterEventListener { |
| 18 | - private $name; |
|
| 19 | - private $ttl; |
|
| 20 | - public function __construct($name, $ttl){ |
|
| 21 | - $this->name = $name; |
|
| 22 | - $this->ttl = $ttl; |
|
| 23 | - } |
|
| 24 | - public function onAddToken(AddTokenResponseEvent $event){ |
|
| 25 | - $response = $event->getResponse(); |
|
| 26 | - $token = $event->getToken(); |
|
| 27 | - $response->headers->setCookie(new Cookie($this->name, $token, time() + $this->ttl, '/', null, false, true)); |
|
| 28 | - } |
|
| 18 | + private $name; |
|
| 19 | + private $ttl; |
|
| 20 | + public function __construct($name, $ttl){ |
|
| 21 | + $this->name = $name; |
|
| 22 | + $this->ttl = $ttl; |
|
| 23 | + } |
|
| 24 | + public function onAddToken(AddTokenResponseEvent $event){ |
|
| 25 | + $response = $event->getResponse(); |
|
| 26 | + $token = $event->getToken(); |
|
| 27 | + $response->headers->setCookie(new Cookie($this->name, $token, time() + $this->ttl, '/', null, false, true)); |
|
| 28 | + } |
|
| 29 | 29 | } |
| 30 | 30 | \ No newline at end of file |
@@ -17,11 +17,11 @@ |
||
| 17 | 17 | class ResponseCookieTokenSetterEventListener { |
| 18 | 18 | private $name; |
| 19 | 19 | private $ttl; |
| 20 | - public function __construct($name, $ttl){ |
|
| 20 | + public function __construct($name, $ttl) { |
|
| 21 | 21 | $this->name = $name; |
| 22 | 22 | $this->ttl = $ttl; |
| 23 | 23 | } |
| 24 | - public function onAddToken(AddTokenResponseEvent $event){ |
|
| 24 | + public function onAddToken(AddTokenResponseEvent $event) { |
|
| 25 | 25 | $response = $event->getResponse(); |
| 26 | 26 | $token = $event->getToken(); |
| 27 | 27 | $response->headers->setCookie(new Cookie($this->name, $token, time() + $this->ttl, '/', null, false, true)); |
@@ -14,17 +14,17 @@ |
||
| 14 | 14 | use Symfony\Component\EventDispatcher\Event; |
| 15 | 15 | |
| 16 | 16 | class GetTokenRequestEvent extends Event { |
| 17 | - private $token = null; |
|
| 18 | - public function __construct(Request $request){ |
|
| 19 | - $this->request = $request; |
|
| 20 | - } |
|
| 21 | - public function getRequest(){ |
|
| 22 | - return $this->request; |
|
| 23 | - } |
|
| 24 | - public function setToken($token){ |
|
| 25 | - $this->token = $token; |
|
| 26 | - } |
|
| 27 | - public function getToken(){ |
|
| 28 | - return $this->token; |
|
| 29 | - } |
|
| 17 | + private $token = null; |
|
| 18 | + public function __construct(Request $request){ |
|
| 19 | + $this->request = $request; |
|
| 20 | + } |
|
| 21 | + public function getRequest(){ |
|
| 22 | + return $this->request; |
|
| 23 | + } |
|
| 24 | + public function setToken($token){ |
|
| 25 | + $this->token = $token; |
|
| 26 | + } |
|
| 27 | + public function getToken(){ |
|
| 28 | + return $this->token; |
|
| 29 | + } |
|
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -15,16 +15,16 @@ |
||
| 15 | 15 | |
| 16 | 16 | class GetTokenRequestEvent extends Event { |
| 17 | 17 | private $token = null; |
| 18 | - public function __construct(Request $request){ |
|
| 18 | + public function __construct(Request $request) { |
|
| 19 | 19 | $this->request = $request; |
| 20 | 20 | } |
| 21 | - public function getRequest(){ |
|
| 21 | + public function getRequest() { |
|
| 22 | 22 | return $this->request; |
| 23 | 23 | } |
| 24 | - public function setToken($token){ |
|
| 24 | + public function setToken($token) { |
|
| 25 | 25 | $this->token = $token; |
| 26 | 26 | } |
| 27 | - public function getToken(){ |
|
| 27 | + public function getToken() { |
|
| 28 | 28 | return $this->token; |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |