mirror of
https://github.com/elyby/accounts.git
synced 2024-12-29 00:20:22 +05:30
44 lines
1.5 KiB
PHP
44 lines
1.5 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace api\components\OAuth2\Grants;
|
|
|
|
use api\components\OAuth2\CryptTrait;
|
|
use api\components\OAuth2\Events\RequestedRefreshToken;
|
|
use api\components\OAuth2\Repositories\PublicScopeRepository;
|
|
use DateInterval;
|
|
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
|
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
|
use League\OAuth2\Server\Grant\AuthCodeGrant as BaseAuthCodeGrant;
|
|
|
|
class AuthCodeGrant extends BaseAuthCodeGrant {
|
|
use CryptTrait;
|
|
|
|
/**
|
|
* @param DateInterval $accessTokenTTL
|
|
* @param ClientEntityInterface $client
|
|
* @param string|null $userIdentifier
|
|
* @param \League\OAuth2\Server\Entities\ScopeEntityInterface[] $scopes
|
|
*
|
|
* @return AccessTokenEntityInterface
|
|
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
|
* @throws \League\OAuth2\Server\Exception\UniqueTokenIdentifierConstraintViolationException
|
|
*/
|
|
protected function issueAccessToken(
|
|
DateInterval $accessTokenTTL,
|
|
ClientEntityInterface $client,
|
|
$userIdentifier,
|
|
array $scopes = []
|
|
): AccessTokenEntityInterface {
|
|
foreach ($scopes as $i => $scope) {
|
|
if ($scope->getIdentifier() === PublicScopeRepository::OFFLINE_ACCESS) {
|
|
unset($scopes[$i]);
|
|
$this->getEmitter()->emit(new RequestedRefreshToken());
|
|
}
|
|
}
|
|
|
|
return parent::issueAccessToken($accessTokenTTL, $client, $userIdentifier, $scopes);
|
|
}
|
|
|
|
}
|