2019-08-23 13:58:04 +05:30
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2024-12-06 06:04:09 +05:30
|
|
|
namespace common\components\OAuth2\Repositories;
|
2019-08-23 13:58:04 +05:30
|
|
|
|
2024-12-06 06:04:09 +05:30
|
|
|
use common\components\OAuth2\Entities\AccessTokenEntity;
|
2019-08-23 13:58:04 +05:30
|
|
|
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
|
|
|
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
|
|
|
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
|
|
|
|
2024-12-06 06:04:09 +05:30
|
|
|
final class AccessTokenRepository implements AccessTokenRepositoryInterface {
|
2019-08-23 13:58:04 +05:30
|
|
|
|
|
|
|
/**
|
2024-12-06 06:04:09 +05:30
|
|
|
* @inheritDoc
|
|
|
|
* @phpstan-param non-empty-string|null $userIdentifier
|
2019-08-23 13:58:04 +05:30
|
|
|
*/
|
2019-09-22 02:47:21 +05:30
|
|
|
public function getNewToken(
|
|
|
|
ClientEntityInterface $clientEntity,
|
|
|
|
array $scopes,
|
2024-12-06 06:04:09 +05:30
|
|
|
?string $userIdentifier = null,
|
2019-09-22 02:47:21 +05:30
|
|
|
): AccessTokenEntityInterface {
|
|
|
|
$accessToken = new AccessTokenEntity();
|
|
|
|
$accessToken->setClient($clientEntity);
|
2024-12-02 15:40:55 +05:30
|
|
|
array_map($accessToken->addScope(...), $scopes);
|
2019-09-22 02:47:21 +05:30
|
|
|
if ($userIdentifier !== null) {
|
|
|
|
$accessToken->setUserIdentifier($userIdentifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $accessToken;
|
2019-08-23 13:58:04 +05:30
|
|
|
}
|
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity): void {
|
|
|
|
// We don't store access tokens, so there's no need to do anything here
|
2019-08-23 13:58:04 +05:30
|
|
|
}
|
|
|
|
|
2024-12-06 06:04:09 +05:30
|
|
|
public function revokeAccessToken(string $tokenId): void {
|
2019-09-22 02:47:21 +05:30
|
|
|
// We don't store access tokens, so there's no need to do anything here
|
2019-08-23 13:58:04 +05:30
|
|
|
}
|
|
|
|
|
2024-12-06 06:04:09 +05:30
|
|
|
public function isAccessTokenRevoked(string $tokenId): bool {
|
2019-09-22 02:47:21 +05:30
|
|
|
return false;
|
2019-08-23 13:58:04 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|