2019-08-23 13:58:04 +05:30
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace api\components\OAuth2\Repositories;
|
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
use api\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;
|
|
|
|
|
|
|
|
class AccessTokenRepository implements AccessTokenRepositoryInterface {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new access token
|
|
|
|
*
|
|
|
|
* @param ClientEntityInterface $clientEntity
|
2019-09-22 02:47:21 +05:30
|
|
|
* @param \League\OAuth2\Server\Entities\ScopeEntityInterface[] $scopes
|
2019-08-23 13:58:04 +05:30
|
|
|
* @param mixed $userIdentifier
|
|
|
|
*
|
|
|
|
* @return AccessTokenEntityInterface
|
|
|
|
*/
|
2019-09-22 02:47:21 +05:30
|
|
|
public function getNewToken(
|
|
|
|
ClientEntityInterface $clientEntity,
|
|
|
|
array $scopes,
|
2024-12-02 15:40:55 +05:30
|
|
|
$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
|
|
|
}
|
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
public function revokeAccessToken($tokenId): void {
|
|
|
|
// We don't store access tokens, so there's no need to do anything here
|
2019-08-23 13:58:04 +05:30
|
|
|
}
|
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
public function isAccessTokenRevoked($tokenId): bool {
|
|
|
|
return false;
|
2019-08-23 13:58:04 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|