Переводим пробелы (по стандарту OAuth2) в наш scopes delimiter.

This commit is contained in:
ErickSkrauch
2017-07-13 13:44:06 +03:00
parent 8adc96a3a8
commit 411ffe0606
3 changed files with 48 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
namespace api\components\OAuth2\Grants;
use api\components\OAuth2\Entities;
use League\OAuth2\Server\Entity\ClientEntity;
class ClientCredentialsGrant extends \League\OAuth2\Server\Grant\ClientCredentialsGrant {
@@ -17,4 +18,19 @@ class ClientCredentialsGrant extends \League\OAuth2\Server\Grant\ClientCredentia
return new Entities\SessionEntity($this->server);
}
/**
* По стандарту OAuth2 scopes должны разделяться пробелом, а не запятой. Косяк.
* Так что оборачиваем функцию разбора скоупов, заменяя пробелы на запятые.
*
* @param string $scopeParam
* @param ClientEntity $client
* @param string $redirectUri
*
* @return \League\OAuth2\Server\Entity\ScopeEntity[]
*/
public function validateScopes($scopeParam = '', ClientEntity $client, $redirectUri = null) {
$scopes = str_replace(' ', $this->server->getScopeDelimiter(), $scopeParam);
return parent::validateScopes($scopes, $client, $redirectUri);
}
}