-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New authenticator for the newer Symfony authenticator API
- Loading branch information
Showing
11 changed files
with
497 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the GesdinetJWTRefreshTokenBundle package. | ||
* | ||
* (c) Gesdinet <http://www.gesdinet.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Gesdinet\JWTRefreshTokenBundle\Event; | ||
|
||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Security\Core\Exception\AuthenticationException; | ||
|
||
class RefreshAuthenticationFailureEvent extends Event | ||
{ | ||
/** | ||
* @var AuthenticationException | ||
*/ | ||
private $exception; | ||
|
||
/** | ||
* @var Response|null | ||
*/ | ||
private $response; | ||
|
||
public function __construct(AuthenticationException $exception, ?Response $response = null) | ||
{ | ||
$this->exception = $exception; | ||
$this->response = $response; | ||
} | ||
|
||
public function getException(): AuthenticationException | ||
{ | ||
return $this->exception; | ||
} | ||
|
||
public function getResponse(): ?Response | ||
{ | ||
return $this->response; | ||
} | ||
|
||
public function setResponse(?Response $response = null): void | ||
{ | ||
$this->response = $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the GesdinetJWTRefreshTokenBundle package. | ||
* | ||
* (c) Gesdinet <http://www.gesdinet.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Gesdinet\JWTRefreshTokenBundle\Event; | ||
|
||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Security\Core\Exception\AuthenticationException; | ||
|
||
class RefreshTokenNotFoundEvent extends Event | ||
{ | ||
/** | ||
* @var AuthenticationException | ||
*/ | ||
private $exception; | ||
|
||
/** | ||
* @var Response|null | ||
*/ | ||
private $response; | ||
|
||
public function __construct(AuthenticationException $exception, ?Response $response = null) | ||
{ | ||
$this->exception = $exception; | ||
$this->response = $response; | ||
} | ||
|
||
public function getException(): AuthenticationException | ||
{ | ||
return $this->exception; | ||
} | ||
|
||
public function getResponse(): ?Response | ||
{ | ||
return $this->response; | ||
} | ||
|
||
public function setResponse(?Response $response = null): void | ||
{ | ||
$this->response = $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the GesdinetJWTRefreshTokenBundle package. | ||
* | ||
* (c) Gesdinet <http://www.gesdinet.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Gesdinet\JWTRefreshTokenBundle\Http; | ||
|
||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class RefreshAuthenticationFailureResponse extends JsonResponse | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $message; | ||
|
||
public function __construct(string $message = 'Bad credentials', int $statusCode = Response::HTTP_UNAUTHORIZED) | ||
{ | ||
$this->message = $message; | ||
|
||
parent::__construct(null, $statusCode); | ||
} | ||
|
||
public function setMessage(string $message): self | ||
{ | ||
$this->message = $message; | ||
|
||
return $this->setData(); | ||
} | ||
|
||
public function getMessage(): string | ||
{ | ||
return $this->message; | ||
} | ||
|
||
public function setData($data = []): self | ||
{ | ||
return parent::setData((array) $data + ['code' => $this->statusCode, 'message' => $this->message]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the GesdinetJWTRefreshTokenBundle package. | ||
* | ||
* (c) Gesdinet <http://www.gesdinet.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Gesdinet\JWTRefreshTokenBundle\Security\Exception; | ||
|
||
use Symfony\Component\Security\Core\Exception\AuthenticationException; | ||
|
||
class InvalidTokenException extends AuthenticationException | ||
{ | ||
public function getMessageKey() | ||
{ | ||
return 'Invalid JWT Refresh Token'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the GesdinetJWTRefreshTokenBundle package. | ||
* | ||
* (c) Gesdinet <http://www.gesdinet.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Gesdinet\JWTRefreshTokenBundle\Security\Exception; | ||
|
||
use Symfony\Component\Security\Core\Exception\AuthenticationException; | ||
|
||
class MissingTokenException extends AuthenticationException | ||
{ | ||
public function getMessageKey() | ||
{ | ||
return 'Missing JWT Refresh Token'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the GesdinetJWTRefreshTokenBundle package. | ||
* | ||
* (c) Gesdinet <http://www.gesdinet.com/> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Gesdinet\JWTRefreshTokenBundle\Security\Exception; | ||
|
||
use Symfony\Component\Security\Core\Exception\AuthenticationException; | ||
|
||
class TokenNotFoundException extends AuthenticationException | ||
{ | ||
public function getMessageKey() | ||
{ | ||
return 'JWT Refresh Token Not Found'; | ||
} | ||
} |
Oops, something went wrong.