mirror of
https://github.com/elyby/accounts.git
synced 2024-12-25 06:39:46 +05:30
50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace api\components\OAuth2\Repositories;
|
|
|
|
use api\components\OAuth2\Entities\AccessTokenEntity;
|
|
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
|
|
* @param \League\OAuth2\Server\Entities\ScopeEntityInterface[] $scopes
|
|
* @param mixed $userIdentifier
|
|
*
|
|
* @return AccessTokenEntityInterface
|
|
*/
|
|
public function getNewToken(
|
|
ClientEntityInterface $clientEntity,
|
|
array $scopes,
|
|
$userIdentifier = null
|
|
): AccessTokenEntityInterface {
|
|
$accessToken = new AccessTokenEntity();
|
|
$accessToken->setClient($clientEntity);
|
|
array_map([$accessToken, 'addScope'], $scopes);
|
|
if ($userIdentifier !== null) {
|
|
$accessToken->setUserIdentifier($userIdentifier);
|
|
}
|
|
|
|
return $accessToken;
|
|
}
|
|
|
|
public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity): void {
|
|
// We don't store access tokens, so there's no need to do anything here
|
|
}
|
|
|
|
public function revokeAccessToken($tokenId): void {
|
|
// We don't store access tokens, so there's no need to do anything here
|
|
}
|
|
|
|
public function isAccessTokenRevoked($tokenId): bool {
|
|
return false;
|
|
}
|
|
|
|
}
|