2016-11-30 01:45:56 +05:30
|
|
|
|
<?php
|
|
|
|
|
namespace api\components\OAuth2\Grants;
|
|
|
|
|
|
|
|
|
|
use api\components\OAuth2\Entities;
|
2017-07-13 16:14:06 +05:30
|
|
|
|
use League\OAuth2\Server\Entity\ClientEntity;
|
2016-11-30 01:45:56 +05:30
|
|
|
|
|
|
|
|
|
class AuthCodeGrant extends \League\OAuth2\Server\Grant\AuthCodeGrant {
|
|
|
|
|
|
|
|
|
|
protected function createAccessTokenEntity() {
|
|
|
|
|
return new Entities\AccessTokenEntity($this->server);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function createRefreshTokenEntity() {
|
|
|
|
|
return new Entities\RefreshTokenEntity($this->server);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function createSessionEntity() {
|
|
|
|
|
return new Entities\SessionEntity($this->server);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-13 16:14:06 +05:30
|
|
|
|
/**
|
|
|
|
|
* По стандарту 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);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-30 01:45:56 +05:30
|
|
|
|
}
|