-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more classes. Upgrade to PHP 7.4
- Loading branch information
Showing
106 changed files
with
3,767 additions
and
155 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
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
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
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
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
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
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,60 @@ | ||
<?php | ||
/* | ||
* This file is part of the StfalconApiBundle. | ||
* | ||
* (c) Stfalcon LLC <stfalcon.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace StfalconStudio\ApiBundle\Error; | ||
|
||
/** | ||
* BaseErrorNames. | ||
*/ | ||
class BaseErrorNames | ||
{ | ||
// 400 | ||
public const MISSED_REQUIRED_HEADER = 'missed_required_header'; | ||
public const MALFORMED_JSON = 'malformed_json'; | ||
public const INVALID_JSON_SCHEMA = 'invalid_json_schema'; | ||
public const INCORRECT_HEADER = 'incorrect_header'; | ||
public const INVALID_REQUEST = 'invalid_request'; | ||
|
||
// 401 | ||
public const UNAUTHORISED_USER = 'unauthorised_user'; | ||
public const INVALID_REFRESH_TOKEN = 'invalid_refresh_token'; | ||
|
||
// 402 | ||
public const INVALID_PAYMENT = 'invalid_payment'; | ||
|
||
// 403 | ||
public const ACCESS_DENIED = 'access_denied'; | ||
public const AUTHORIZED_USER = 'authorized_user'; | ||
|
||
// 404 | ||
public const RESOURCE_NOT_FOUND = 'resource_not_found'; | ||
|
||
// 405 | ||
public const METHOD_NOT_ALLOWED = 'method_not_allowed'; | ||
|
||
// 409 | ||
public const CONFLICT_TARGET_RESOURCE_UPDATE = 'conflict_target_resource_update'; | ||
|
||
// 422 | ||
public const INVALID_ENTITY = 'invalid_entity'; | ||
|
||
// 500 | ||
public const INTERNAL_SERVER_ERROR = 'internal_server_error'; | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
private function __construct() | ||
{ | ||
// noop | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
/* | ||
* This file is part of the StfalconApiBundle. | ||
* | ||
* (c) Stfalcon LLC <stfalcon.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace StfalconStudio\ApiBundle\EventListener\JWT; | ||
|
||
use Gesdinet\JWTRefreshTokenBundle\Event\RefreshEvent; | ||
use StfalconStudio\ApiBundle\Entity\JWT\RefreshToken; | ||
use StfalconStudio\ApiBundle\Exception\JWT\InvalidRefreshTokenException; | ||
use StfalconStudio\ApiBundle\Model\Credentials\CredentialsInterface; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
/** | ||
* JwtRefreshSubscriber. | ||
*/ | ||
final class JwtRefreshSubscriber implements EventSubscriberInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function getSubscribedEvents(): iterable | ||
{ | ||
yield 'gesdinet.refresh_token' => 'processRefreshToken'; | ||
yield RefreshEvent::class => 'processRefreshToken'; | ||
} | ||
|
||
/** | ||
* @param RefreshEvent $event | ||
* | ||
* @throws InvalidRefreshTokenException | ||
*/ | ||
public function processRefreshToken(RefreshEvent $event): void | ||
{ | ||
$user = $event->getPreAuthenticatedToken()->getUser(); | ||
|
||
if ($user instanceof CredentialsInterface) { | ||
$refreshToken = $event->getRefreshToken(); | ||
|
||
if ($refreshToken instanceof RefreshToken) { | ||
$userCredentialsLastChangedAt = $user->getCredentialsLastChangedAt(); | ||
$refreshTokenCreatedAt = $refreshToken->getCreatedAt()->getTimestamp(); | ||
|
||
if ($userCredentialsLastChangedAt instanceof \DateTimeInterface && $refreshTokenCreatedAt < $userCredentialsLastChangedAt->getTimestamp()) { | ||
throw new InvalidRefreshTokenException(); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.