diff --git a/app/Http/Middleware/OAuth2BearerAccessTokenRequestValidator.php b/app/Http/Middleware/OAuth2BearerAccessTokenRequestValidator.php index 26615fdd..6efc3c43 100644 --- a/app/Http/Middleware/OAuth2BearerAccessTokenRequestValidator.php +++ b/app/Http/Middleware/OAuth2BearerAccessTokenRequestValidator.php @@ -160,11 +160,9 @@ class OAuth2BearerAccessTokenRequestValidator } //check scopes Log::debug('checking token scopes ...'); - $endpoint_scopes = $endpoint->getScope(); - Log::debug(sprintf("endpoint scopes %s", $endpoint_scopes)); + $endpoint_scopes = $endpoint->getScopesNames(); + Log::debug(sprintf("endpoint scopes %s", implode(' ',$endpoint_scopes))); Log::debug(sprintf("token scopes %s", $token_info->getScope())); - - $endpoint_scopes = explode(' ', $endpoint_scopes); $token_scopes = explode(' ', $token_info->getScope()); //check token available scopes vs. endpoint scopes diff --git a/app/Models/ResourceServer/ApiEndpoint.php b/app/Models/ResourceServer/ApiEndpoint.php index 78d12da4..b74310c1 100644 --- a/app/Models/ResourceServer/ApiEndpoint.php +++ b/app/Models/ResourceServer/ApiEndpoint.php @@ -255,26 +255,28 @@ class ApiEndpoint extends ResourceServerEntity implements IApiEndpoint /** * @return string */ - public function getScope() + public function getFriendlyScopes():string { - return CacheFacade::remember - ( - 'endpoint_scopes_'.$this->id, - Config::get("cache_regions.region_api_scopes_lifetime", 1140), - function() { - $scope = ''; - foreach ($this->scopes as $s) { - if (!$s->isActive()) { - continue; - } - $scope = $scope . $s->getName() . ' '; - } - $scope = trim($scope); - return $scope; - } - ); + $scopes = $this->getScopesNames(); + return implode(' ', $scopes); } + /** + * @return string[] + */ + public function getScopesNames(): array { + $scopes = []; + + foreach ($this->scopes as $s) { + if (!$s->isActive()) { + continue; + } + $scopes[] = $s->getName(); + } + + return $scopes; + } + /** * @param IApiScope $scope */ diff --git a/app/Models/ResourceServer/IApiEndpoint.php b/app/Models/ResourceServer/IApiEndpoint.php index 502360f2..4b702f28 100644 --- a/app/Models/ResourceServer/IApiEndpoint.php +++ b/app/Models/ResourceServer/IApiEndpoint.php @@ -57,7 +57,12 @@ interface IApiEndpoint extends IEntity /** * @return string */ - public function getScope(); + public function getFriendlyScopes(); + + /** + * @return string[] + */ + public function getScopesNames(): array; /** * @return bool