2016-11-30 01:45:56 +05:30
|
|
|
<?php
|
2019-09-22 02:47:21 +05:30
|
|
|
declare(strict_types=1);
|
2017-06-17 23:35:36 +05:30
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
namespace api\components\OAuth2\Grants;
|
2017-06-17 23:35:36 +05:30
|
|
|
|
2019-12-06 17:07:51 +05:30
|
|
|
use api\components\OAuth2\CryptTrait;
|
2019-09-22 02:47:21 +05:30
|
|
|
use api\components\OAuth2\Repositories\PublicScopeRepository;
|
|
|
|
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
|
|
|
use League\OAuth2\Server\Entities\RefreshTokenEntityInterface;
|
|
|
|
use League\OAuth2\Server\Grant\AuthCodeGrant as BaseAuthCodeGrant;
|
2017-06-17 23:35:36 +05:30
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
class AuthCodeGrant extends BaseAuthCodeGrant {
|
2019-12-06 17:07:51 +05:30
|
|
|
use CryptTrait;
|
2017-06-17 23:35:36 +05:30
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
protected function issueRefreshToken(AccessTokenEntityInterface $accessToken): ?RefreshTokenEntityInterface {
|
|
|
|
foreach ($accessToken->getScopes() as $scope) {
|
|
|
|
if ($scope->getIdentifier() === PublicScopeRepository::OFFLINE_ACCESS) {
|
|
|
|
return parent::issueRefreshToken($accessToken);
|
|
|
|
}
|
2017-06-17 23:35:36 +05:30
|
|
|
}
|
|
|
|
|
2019-09-22 02:47:21 +05:30
|
|
|
return null;
|
2017-07-13 16:14:06 +05:30
|
|
|
}
|
|
|
|
|
2016-11-30 01:45:56 +05:30
|
|
|
}
|