2016-11-29 23:15:56 +03:00
|
|
|
<?php
|
2019-09-22 00:17:21 +03:00
|
|
|
declare(strict_types=1);
|
2017-06-17 21:05:36 +03:00
|
|
|
|
2019-09-22 00:17:21 +03:00
|
|
|
namespace api\components\OAuth2\Grants;
|
2017-06-17 21:05:36 +03:00
|
|
|
|
2019-09-22 00:17:21 +03:00
|
|
|
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 21:05:36 +03:00
|
|
|
|
2019-09-22 00:17:21 +03:00
|
|
|
class AuthCodeGrant extends BaseAuthCodeGrant {
|
2017-06-17 21:05:36 +03:00
|
|
|
|
2019-09-22 00:17:21 +03:00
|
|
|
protected function issueRefreshToken(AccessTokenEntityInterface $accessToken): ?RefreshTokenEntityInterface {
|
|
|
|
foreach ($accessToken->getScopes() as $scope) {
|
|
|
|
if ($scope->getIdentifier() === PublicScopeRepository::OFFLINE_ACCESS) {
|
|
|
|
return parent::issueRefreshToken($accessToken);
|
|
|
|
}
|
2017-06-17 21:05:36 +03:00
|
|
|
}
|
|
|
|
|
2019-09-22 00:17:21 +03:00
|
|
|
return null;
|
2017-07-13 13:44:06 +03:00
|
|
|
}
|
|
|
|
|
2016-11-29 23:15:56 +03:00
|
|
|
}
|