mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-09 05:23:53 +05:30
CS fixer changes
This commit is contained in:
parent
193018aecf
commit
97e7a00bca
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server;
|
namespace League\OAuth2\Server;
|
||||||
|
|
||||||
use League\OAuth2\Server\Exception;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,6 +40,7 @@ abstract class AbstractServer
|
|||||||
public function setRequest(Request $request)
|
public function setRequest(Request $request)
|
||||||
{
|
{
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ abstract class AbstractServer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a storage class
|
* Return a storage class
|
||||||
* @param string $obj The class required
|
* @param string $obj The class required
|
||||||
* @return Storage\ClientInterface|Storage\ScopeInterface|Storage\SessionInterface
|
* @return Storage\ClientInterface|Storage\ScopeInterface|Storage\SessionInterface
|
||||||
*/
|
*/
|
||||||
public function getStorage($obj)
|
public function getStorage($obj)
|
||||||
@ -69,6 +69,7 @@ abstract class AbstractServer
|
|||||||
'The `'.$obj.'` storage interface has not been registered with the server'
|
'The `'.$obj.'` storage interface has not been registered with the server'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->storages[$obj];
|
return $this->storages[$obj];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,7 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server;
|
namespace League\OAuth2\Server;
|
||||||
|
|
||||||
use League\OAuth2\Server\Util\SecureKey;
|
|
||||||
use League\OAuth2\Server\Grant\GrantTypeInterface;
|
use League\OAuth2\Server\Grant\GrantTypeInterface;
|
||||||
use League\OAuth2\Server\Exception;
|
|
||||||
use League\OAuth2\Server\Storage\StorageWrapper;
|
|
||||||
use League\OAuth2\Server\Storage\ClientInterface;
|
use League\OAuth2\Server\Storage\ClientInterface;
|
||||||
use League\OAuth2\Server\Storage\AccessTokenInterface;
|
use League\OAuth2\Server\Storage\AccessTokenInterface;
|
||||||
use League\OAuth2\Server\Storage\AuthCodeInterface;
|
use League\OAuth2\Server\Storage\AuthCodeInterface;
|
||||||
@ -78,85 +75,92 @@ class AuthorizationServer extends AbstractServer
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->storages = [];
|
$this->storages = [];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the client storage
|
* Set the client storage
|
||||||
* @param ClientInterface $storage
|
* @param ClientInterface $storage
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setClientStorage(ClientInterface $storage)
|
public function setClientStorage(ClientInterface $storage)
|
||||||
{
|
{
|
||||||
$storage->setServer($this);
|
$storage->setServer($this);
|
||||||
$this->storages['client'] = $storage;
|
$this->storages['client'] = $storage;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the session storage
|
* Set the session storage
|
||||||
* @param SessionInterface $storage
|
* @param SessionInterface $storage
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setSessionStorage(SessionInterface $storage)
|
public function setSessionStorage(SessionInterface $storage)
|
||||||
{
|
{
|
||||||
$storage->setServer($this);
|
$storage->setServer($this);
|
||||||
$this->storages['session'] = $storage;
|
$this->storages['session'] = $storage;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the access token storage
|
* Set the access token storage
|
||||||
* @param AccessTokenInterface $storage
|
* @param AccessTokenInterface $storage
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setAccessTokenStorage(AccessTokenInterface $storage)
|
public function setAccessTokenStorage(AccessTokenInterface $storage)
|
||||||
{
|
{
|
||||||
$storage->setServer($this);
|
$storage->setServer($this);
|
||||||
$this->storages['access_token'] = $storage;
|
$this->storages['access_token'] = $storage;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the refresh token storage
|
* Set the refresh token storage
|
||||||
* @param RefreshTokenInteface $storage
|
* @param RefreshTokenInteface $storage
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setRefreshTokenStorage(RefreshTokenInterface $storage)
|
public function setRefreshTokenStorage(RefreshTokenInterface $storage)
|
||||||
{
|
{
|
||||||
$storage->setServer($this);
|
$storage->setServer($this);
|
||||||
$this->storages['refresh_token'] = $storage;
|
$this->storages['refresh_token'] = $storage;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the auth code storage
|
* Set the auth code storage
|
||||||
* @param AuthCodeInterface $authCode
|
* @param AuthCodeInterface $authCode
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setAuthCodeStorage(AuthCodeInterface $storage)
|
public function setAuthCodeStorage(AuthCodeInterface $storage)
|
||||||
{
|
{
|
||||||
$storage->setServer($this);
|
$storage->setServer($this);
|
||||||
$this->storages['auth_code'] = $storage;
|
$this->storages['auth_code'] = $storage;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the scope storage
|
* Set the scope storage
|
||||||
* @param ScopeInterface $storage
|
* @param ScopeInterface $storage
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setScopeStorage(ScopeInterface $storage)
|
public function setScopeStorage(ScopeInterface $storage)
|
||||||
{
|
{
|
||||||
$storage->setServer($this);
|
$storage->setServer($this);
|
||||||
$this->storages['scope'] = $storage;
|
$this->storages['scope'] = $storage;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable support for a grant
|
* Enable support for a grant
|
||||||
* @param GrantTypeInterface $grantType A grant class which conforms to Interface/GrantTypeInterface
|
* @param GrantTypeInterface $grantType A grant class which conforms to Interface/GrantTypeInterface
|
||||||
* @param null|string $identifier An identifier for the grant (autodetected if not passed)
|
* @param null|string $identifier An identifier for the grant (autodetected if not passed)
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function addGrantType(GrantTypeInterface $grantType, $identifier = null)
|
public function addGrantType(GrantTypeInterface $grantType, $identifier = null)
|
||||||
@ -204,6 +208,7 @@ class AuthorizationServer extends AbstractServer
|
|||||||
public function requireScopeParam($require = true)
|
public function requireScopeParam($require = true)
|
||||||
{
|
{
|
||||||
$this->requireScopeParam = $require;
|
$this->requireScopeParam = $require;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,6 +229,7 @@ class AuthorizationServer extends AbstractServer
|
|||||||
public function setDefaultScope($default = null)
|
public function setDefaultScope($default = null)
|
||||||
{
|
{
|
||||||
$this->defaultScope = $default;
|
$this->defaultScope = $default;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,6 +260,7 @@ class AuthorizationServer extends AbstractServer
|
|||||||
public function requireStateParam($require = true)
|
public function requireStateParam($require = true)
|
||||||
{
|
{
|
||||||
$this->requireStateParam = $require;
|
$this->requireStateParam = $require;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +280,7 @@ class AuthorizationServer extends AbstractServer
|
|||||||
public function setScopeDelimeter($scopeDelimeter = ' ')
|
public function setScopeDelimeter($scopeDelimeter = ' ')
|
||||||
{
|
{
|
||||||
$this->scopeDelimeter = $scopeDelimeter;
|
$this->scopeDelimeter = $scopeDelimeter;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,6 +300,7 @@ class AuthorizationServer extends AbstractServer
|
|||||||
public function setAccessTokenTTL($accessTokenTTL = 3600)
|
public function setAccessTokenTTL($accessTokenTTL = 3600)
|
||||||
{
|
{
|
||||||
$this->accessTokenTTL = $accessTokenTTL;
|
$this->accessTokenTTL = $accessTokenTTL;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +326,7 @@ class AuthorizationServer extends AbstractServer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a grant type class
|
* Return a grant type class
|
||||||
* @param string $grantType The grant type identifer
|
* @param string $grantType The grant type identifer
|
||||||
* @return Grant\GrantTypeInterface
|
* @return Grant\GrantTypeInterface
|
||||||
*/
|
*/
|
||||||
public function getGrantType($grantType)
|
public function getGrantType($grantType)
|
||||||
|
@ -11,9 +11,7 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Entity;
|
namespace League\OAuth2\Server\Entity;
|
||||||
|
|
||||||
use League\OAuth2\Server\Storage\SessionStorageInterface;
|
|
||||||
use League\OAuth2\Server\Util\SecureKey;
|
use League\OAuth2\Server\Util\SecureKey;
|
||||||
use League\OAuth2\Server\Exception\ServerException;
|
|
||||||
use League\OAuth2\Server\AbstractServer;
|
use League\OAuth2\Server\AbstractServer;
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
|
|
||||||
@ -54,34 +52,37 @@ abstract class AbstractTokenEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* __construct
|
* __construct
|
||||||
* @param \League\OAuth2\Server\AbstractServer $server
|
* @param \League\OAuth2\Server\AbstractServer $server
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function __construct(AbstractServer $server)
|
public function __construct(AbstractServer $server)
|
||||||
{
|
{
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set session
|
* Set session
|
||||||
* @param \League\OAuth2\Server\SessionEntity $session
|
* @param \League\OAuth2\Server\SessionEntity $session
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setSession(SessionEntity $session)
|
public function setSession(SessionEntity $session)
|
||||||
{
|
{
|
||||||
$this->session = $session;
|
$this->session = $session;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the expire time of the token
|
* Set the expire time of the token
|
||||||
* @param integer $expireTime Unix time stamp
|
* @param integer $expireTime Unix time stamp
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setExpireTime($expireTime)
|
public function setExpireTime($expireTime)
|
||||||
{
|
{
|
||||||
$this->expireTime = $expireTime;
|
$this->expireTime = $expireTime;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,12 +97,13 @@ abstract class AbstractTokenEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set access token ID
|
* Set access token ID
|
||||||
* @param string $token Token ID
|
* @param string $token Token ID
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setToken($token = null)
|
public function setToken($token = null)
|
||||||
{
|
{
|
||||||
$this->token = ($token !== null) ? $token : SecureKey::generate();
|
$this->token = ($token !== null) ? $token : SecureKey::generate();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +118,7 @@ abstract class AbstractTokenEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate a scope
|
* Associate a scope
|
||||||
* @param \League\OAuth2\Server\Entity\ScopeEntity $scope
|
* @param \League\OAuth2\Server\Entity\ScopeEntity $scope
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function associateScope(ScopeEntity $scope)
|
public function associateScope(ScopeEntity $scope)
|
||||||
@ -141,6 +143,7 @@ abstract class AbstractTokenEntity
|
|||||||
$scopes[$scope->getId()] = $scope;
|
$scopes[$scope->getId()] = $scope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $scopes;
|
return $scopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,12 +11,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Entity;
|
namespace League\OAuth2\Server\Entity;
|
||||||
|
|
||||||
use League\OAuth2\Server\Storage\SessionStorageInterface;
|
|
||||||
use League\OAuth2\Server\Storage\AccessTokenInterface;
|
|
||||||
use League\OAuth2\Server\Util\SecureKey;
|
|
||||||
use League\OAuth2\Server\Exception\InvalidAccessTokenException;
|
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access token entity class
|
* Access token entity class
|
||||||
*/
|
*/
|
||||||
@ -33,12 +27,13 @@ class AccessTokenEntity extends AbstractTokenEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->session = $this->server->getStorage('session')->getByAccessToken($this);
|
$this->session = $this->server->getStorage('session')->getByAccessToken($this);
|
||||||
|
|
||||||
return $this->session;
|
return $this->session;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if access token has an associated scope
|
* Check if access token has an associated scope
|
||||||
* @param string $scope Scope to check
|
* @param string $scope Scope to check
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasScope($scope)
|
public function hasScope($scope)
|
||||||
|
@ -11,12 +11,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Entity;
|
namespace League\OAuth2\Server\Entity;
|
||||||
|
|
||||||
use League\OAuth2\Server\Storage\SessionStorageInterface;
|
|
||||||
use League\OAuth2\Server\Storage\AccessTokenInterface;
|
|
||||||
use League\OAuth2\Server\Util\SecureKey;
|
|
||||||
use League\OAuth2\Server\Exception\InvalidAccessTokenException;
|
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access token entity class
|
* Access token entity class
|
||||||
*/
|
*/
|
||||||
@ -30,18 +24,19 @@ class AuthCodeEntity extends AbstractTokenEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the redirect URI for the authorization request
|
* Set the redirect URI for the authorization request
|
||||||
* @param string $redirectUri
|
* @param string $redirectUri
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setRedirectUri($redirectUri)
|
public function setRedirectUri($redirectUri)
|
||||||
{
|
{
|
||||||
$this->redirectUri = $redirectUri;
|
$this->redirectUri = $redirectUri;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the redirect URI
|
* Get the redirect URI
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getRedirectUri()
|
public function getRedirectUri()
|
||||||
{
|
{
|
||||||
@ -58,6 +53,7 @@ class AuthCodeEntity extends AbstractTokenEntity
|
|||||||
{
|
{
|
||||||
$uri = $this->getRedirectUri();
|
$uri = $this->getRedirectUri();
|
||||||
$uri .= (strstr($this->getRedirectUri(), $queryDelimeter) === false) ? $queryDelimeter : '&';
|
$uri .= (strstr($this->getRedirectUri(), $queryDelimeter) === false) ? $queryDelimeter : '&';
|
||||||
|
|
||||||
return $uri.http_build_query([
|
return $uri.http_build_query([
|
||||||
'code' => $this->getToken(),
|
'code' => $this->getToken(),
|
||||||
'state' => $state
|
'state' => $state
|
||||||
@ -74,6 +70,7 @@ class AuthCodeEntity extends AbstractTokenEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->session = $this->server->getStorage('session')->getByAuthCode($this);
|
$this->session = $this->server->getStorage('session')->getByAuthCode($this);
|
||||||
|
|
||||||
return $this->session;
|
return $this->session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Entity;
|
namespace League\OAuth2\Server\Entity;
|
||||||
|
|
||||||
use League\OAuth2\Server\Exception\ServerException;
|
|
||||||
use League\OAuth2\Server\AbstractServer;
|
use League\OAuth2\Server\AbstractServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,23 +50,25 @@ class ClientEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* __construct
|
* __construct
|
||||||
* @param \League\OAuth2\Server\AbstractServer $server
|
* @param \League\OAuth2\Server\AbstractServer $server
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function __construct(AbstractServer $server)
|
public function __construct(AbstractServer $server)
|
||||||
{
|
{
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the client identifier
|
* Set the client identifier
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setId($id)
|
public function setId($id)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,12 +83,13 @@ class ClientEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the client secret
|
* Set the client secret
|
||||||
* @param string $secret
|
* @param string $secret
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setSecret($secret)
|
public function setSecret($secret)
|
||||||
{
|
{
|
||||||
$this->secret = $secret;
|
$this->secret = $secret;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,12 +104,13 @@ class ClientEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the client name
|
* Set the client name
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setName($name)
|
public function setName($name)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,12 +125,13 @@ class ClientEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the client redirect URI
|
* Set the client redirect URI
|
||||||
* @param string $redirectUri
|
* @param string $redirectUri
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setRedirectUri($redirectUri)
|
public function setRedirectUri($redirectUri)
|
||||||
{
|
{
|
||||||
$this->redirectUri = $redirectUri;
|
$this->redirectUri = $redirectUri;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,12 +11,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Entity;
|
namespace League\OAuth2\Server\Entity;
|
||||||
|
|
||||||
use League\OAuth2\Server\Storage\SessionStorageInterface;
|
|
||||||
use League\OAuth2\Server\Storage\RefreshTokenInterface;
|
|
||||||
use League\OAuth2\Server\Util\SecureKey;
|
|
||||||
use League\OAuth2\Server\Exception\InvalidAccessTokenException;
|
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh token entity class
|
* Refresh token entity class
|
||||||
*/
|
*/
|
||||||
@ -30,12 +24,13 @@ class RefreshTokenEntity extends AbstractTokenEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate an access token
|
* Associate an access token
|
||||||
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken
|
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setAccessToken(AccessTokenEntity $accessToken)
|
public function setAccessToken(AccessTokenEntity $accessToken)
|
||||||
{
|
{
|
||||||
$this->accessToken = $accessToken;
|
$this->accessToken = $accessToken;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +43,7 @@ class RefreshTokenEntity extends AbstractTokenEntity
|
|||||||
if (! $this->accessToken instanceof AccessTokenEntity) {
|
if (! $this->accessToken instanceof AccessTokenEntity) {
|
||||||
$this->accessToken = $this->server->getStorage('access_token')->getByRefreshToken($this);
|
$this->accessToken = $this->server->getStorage('access_token')->getByRefreshToken($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->accessToken;
|
return $this->accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Entity;
|
namespace League\OAuth2\Server\Entity;
|
||||||
|
|
||||||
use League\OAuth2\Server\Exception\ServerException;
|
|
||||||
use League\OAuth2\Server\AbstractServer;
|
use League\OAuth2\Server\AbstractServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,23 +38,25 @@ class ScopeEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* __construct
|
* __construct
|
||||||
* @param \League\OAuth2\Server\AbstractServer $server
|
* @param \League\OAuth2\Server\AbstractServer $server
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function __construct(AbstractServer $server)
|
public function __construct(AbstractServer $server)
|
||||||
{
|
{
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the scope identifer
|
* Set the scope identifer
|
||||||
* @param string $id The scope identifier
|
* @param string $id The scope identifier
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setId($id)
|
public function setId($id)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,12 +71,13 @@ class ScopeEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the scope's descripton
|
* Set the scope's descripton
|
||||||
* @param string $description
|
* @param string $description
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setDescription($description)
|
public function setDescription($description)
|
||||||
{
|
{
|
||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,4 +89,4 @@ class ScopeEntity
|
|||||||
{
|
{
|
||||||
return $this->description;
|
return $this->description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Entity;
|
namespace League\OAuth2\Server\Entity;
|
||||||
|
|
||||||
use League\OAuth2\Server\Exception\OAuth2Exception;
|
|
||||||
use League\OAuth2\Server\Storage\SessionInterface;
|
|
||||||
use League\OAuth2\Server\Exception\ServerException;
|
|
||||||
use League\OAuth2\Server\AbstractServer;
|
use League\OAuth2\Server\AbstractServer;
|
||||||
use Symfony\Component\HttpFoundation\ParameterBag;
|
use Symfony\Component\HttpFoundation\ParameterBag;
|
||||||
|
|
||||||
@ -78,23 +75,25 @@ class SessionEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* __construct
|
* __construct
|
||||||
* @param \League\OAuth2\Server\AbstractServer $server
|
* @param \League\OAuth2\Server\AbstractServer $server
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function __construct(AbstractServer $server)
|
public function __construct(AbstractServer $server)
|
||||||
{
|
{
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the session identifier
|
* Set the session identifier
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setId($id)
|
public function setId($id)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +108,7 @@ class SessionEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate a scope
|
* Associate a scope
|
||||||
* @param \League\OAuth2\Server\Entity\ScopeEntity $scope
|
* @param \League\OAuth2\Server\Entity\ScopeEntity $scope
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function associateScope(ScopeEntity $scope)
|
public function associateScope(ScopeEntity $scope)
|
||||||
@ -123,7 +122,7 @@ class SessionEntity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if access token has an associated scope
|
* Check if access token has an associated scope
|
||||||
* @param string $scope Scope to check
|
* @param string $scope Scope to check
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasScope($scope)
|
public function hasScope($scope)
|
||||||
@ -163,6 +162,7 @@ class SessionEntity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $scopes;
|
return $scopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,6 +174,7 @@ class SessionEntity
|
|||||||
public function associateAccessToken(AccessTokenEntity $accessToken)
|
public function associateAccessToken(AccessTokenEntity $accessToken)
|
||||||
{
|
{
|
||||||
$this->accessToken = $accessToken;
|
$this->accessToken = $accessToken;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,6 +186,7 @@ class SessionEntity
|
|||||||
public function associateRefreshToken(RefreshTokenEntity $refreshToken)
|
public function associateRefreshToken(RefreshTokenEntity $refreshToken)
|
||||||
{
|
{
|
||||||
$this->refreshToken = $refreshToken;
|
$this->refreshToken = $refreshToken;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,6 +198,7 @@ class SessionEntity
|
|||||||
public function associateClient(ClientEntity $client)
|
public function associateClient(ClientEntity $client)
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,13 +213,14 @@ class SessionEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->client = $this->server->getStorage('client')->getBySession($this);
|
$this->client = $this->server->getStorage('client')->getBySession($this);
|
||||||
|
|
||||||
return $this->client;
|
return $this->client;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the session owner
|
* Set the session owner
|
||||||
* @param string $type The type of the owner (e.g. user, app)
|
* @param string $type The type of the owner (e.g. user, app)
|
||||||
* @param string $id The identifier of the owner
|
* @param string $id The identifier of the owner
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setOwner($type, $id)
|
public function setOwner($type, $id)
|
||||||
|
@ -36,7 +36,7 @@ class OAuthException extends \Exception
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all headers that have to be send with the error response
|
* Get all headers that have to be send with the error response
|
||||||
* @return array Array with header values
|
* @return array Array with header values
|
||||||
*/
|
*/
|
||||||
public function getHttpHeaders()
|
public function getHttpHeaders()
|
||||||
{
|
{
|
||||||
@ -86,7 +86,6 @@ class OAuthException extends \Exception
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
return $headers;
|
return $headers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,12 +61,13 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the identifier
|
* Return the identifier
|
||||||
* @param string $identifier
|
* @param string $identifier
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setIdentifier($identifier)
|
public function setIdentifier($identifier)
|
||||||
{
|
{
|
||||||
$this->identifier = $identifier;
|
$this->identifier = $identifier;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,29 +82,31 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Override the default access token expire time
|
* Override the default access token expire time
|
||||||
* @param int $accessTokenTTL
|
* @param int $accessTokenTTL
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setAccessTokenTTL($accessTokenTTL)
|
public function setAccessTokenTTL($accessTokenTTL)
|
||||||
{
|
{
|
||||||
$this->accessTokenTTL = $accessTokenTTL;
|
$this->accessTokenTTL = $accessTokenTTL;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inject the authorization server into the grant
|
* Inject the authorization server into the grant
|
||||||
* @param AuthorizationServer $server The authorization server instance
|
* @param AuthorizationServer $server The authorization server instance
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setAuthorizationServer(AuthorizationServer $server)
|
public function setAuthorizationServer(AuthorizationServer $server)
|
||||||
{
|
{
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a list of scopes, validate them and return an arrary of Scope entities
|
* Given a list of scopes, validate them and return an arrary of Scope entities
|
||||||
* @param string $scopeParam A string of scopes (e.g. "profile email birthday")
|
* @param string $scopeParam A string of scopes (e.g. "profile email birthday")
|
||||||
* @return array
|
* @return array
|
||||||
* @throws ClientException If scope is invalid, or no scopes passed when required
|
* @throws ClientException If scope is invalid, or no scopes passed when required
|
||||||
*/
|
*/
|
||||||
@ -161,6 +164,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
$scopes[$scope->getId()] = $scope;
|
$scopes[$scope->getId()] = $scope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $scopes;
|
return $scopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,15 +174,15 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
* Example response:
|
* Example response:
|
||||||
* <pre>
|
* <pre>
|
||||||
* array(
|
* array(
|
||||||
* 'access_token' => (string), // The access token
|
* 'access_token' => (string) , // The access token
|
||||||
* 'refresh_token' => (string), // The refresh token (only set if the refresh token grant is enabled)
|
* 'refresh_token' => (string) , // The refresh token (only set if the refresh token grant is enabled)
|
||||||
* 'token_type' => 'bearer', // Almost always "bearer" (exceptions: JWT, SAML)
|
* 'token_type' => 'bearer', // Almost always "bearer" (exceptions: JWT, SAML)
|
||||||
* 'expires' => (int), // The timestamp of when the access token will expire
|
* 'expires' => (int) , // The timestamp of when the access token will expire
|
||||||
* 'expires_in' => (int) // The number of seconds before the access token will expire
|
* 'expires_in' => (int) // The number of seconds before the access token will expire
|
||||||
* )
|
* )
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @return array An array of parameters to be passed back to the client
|
* @return array An array of parameters to be passed back to the client
|
||||||
*/
|
*/
|
||||||
abstract public function completeFlow();
|
abstract public function completeFlow();
|
||||||
|
|
||||||
|
@ -11,19 +11,14 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
use League\OAuth2\Server\AuthorizationServer;
|
|
||||||
use League\OAuth2\Server\Request;
|
use League\OAuth2\Server\Request;
|
||||||
use League\OAuth2\Server\Exception;
|
use League\OAuth2\Server\Exception;
|
||||||
use League\OAuth2\Server\Entity\ClientEntity;
|
use League\OAuth2\Server\Entity\ClientEntity;
|
||||||
use League\OAuth2\Server\Entity\RefreshTokenEntity;
|
use League\OAuth2\Server\Entity\RefreshTokenEntity;
|
||||||
use League\OAuth2\Server\Entity\SessionEntity;
|
use League\OAuth2\Server\Entity\SessionEntity;
|
||||||
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
||||||
use League\OAuth2\Server\Entity\ScopeEntity;
|
|
||||||
use League\OAuth2\Server\Entity\AuthCodeEntity;
|
use League\OAuth2\Server\Entity\AuthCodeEntity;
|
||||||
use League\OAuth2\Server\Util\SecureKey;
|
use League\OAuth2\Server\Util\SecureKey;
|
||||||
use League\OAuth2\Server\Storage\SessionInterface;
|
|
||||||
use League\OAuth2\Server\Storage\ClientInterface;
|
|
||||||
use League\OAuth2\Server\Storage\ScopeInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auth code grant class
|
* Auth code grant class
|
||||||
@ -62,7 +57,7 @@ class AuthCodeGrant extends AbstractGrant
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Override the default access token expire time
|
* Override the default access token expire time
|
||||||
* @param int $authTokenTTL
|
* @param int $authTokenTTL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setAuthTokenTTL($authTokenTTL)
|
public function setAuthTokenTTL($authTokenTTL)
|
||||||
@ -132,10 +127,10 @@ class AuthCodeGrant extends AbstractGrant
|
|||||||
/**
|
/**
|
||||||
* Parse a new authorise request
|
* Parse a new authorise request
|
||||||
*
|
*
|
||||||
* @param string $type The session owner's type
|
* @param string $type The session owner's type
|
||||||
* @param string $typeId The session owner's ID
|
* @param string $typeId The session owner's ID
|
||||||
* @param array $authParams The authorise request $_GET parameters
|
* @param array $authParams The authorise request $_GET parameters
|
||||||
* @return string An authorisation code
|
* @return string An authorisation code
|
||||||
*/
|
*/
|
||||||
public function newAuthoriseRequest($type, $typeId, $authParams = [])
|
public function newAuthoriseRequest($type, $typeId, $authParams = [])
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user