mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-08 21:14:00 +05:30
More CS fixer changes
This commit is contained in:
parent
97e7a00bca
commit
ed7f5370ca
@ -11,16 +11,11 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
use League\OAuth2\Server\AuthorizationServer;
|
|
||||||
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
||||||
use League\OAuth2\Server\Entity\ClientEntity;
|
use League\OAuth2\Server\Entity\ClientEntity;
|
||||||
use League\OAuth2\Server\Entity\SessionEntity;
|
use League\OAuth2\Server\Entity\SessionEntity;
|
||||||
use League\OAuth2\Server\Entity\ScopeEntity;
|
|
||||||
use League\OAuth2\Server\Exception;
|
use League\OAuth2\Server\Exception;
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client credentials grant class
|
* Client credentials grant class
|
||||||
|
@ -11,14 +11,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
use League\OAuth2\Server\Request;
|
|
||||||
use League\OAuth2\Server\Authorization;
|
|
||||||
use League\OAuth2\Server\Exception;
|
|
||||||
use League\OAuth2\Server\Util\SecureKey;
|
|
||||||
use League\OAuth2\Server\Storage\SessionInterface;
|
|
||||||
use League\OAuth2\Server\Storage\ClientInterface;
|
|
||||||
use League\OAuth2\Server\Storage\ScopeInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grant type interface
|
* Grant type interface
|
||||||
*/
|
*/
|
||||||
@ -26,7 +18,7 @@ interface GrantTypeInterface
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Complete the grant flow
|
* Complete the grant flow
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function completeFlow();
|
public function completeFlow();
|
||||||
}
|
}
|
||||||
|
@ -11,17 +11,12 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
use League\OAuth2\Server\AuthorizationServer;
|
|
||||||
use League\OAuth2\Server\Entity\ClientEntity;
|
use League\OAuth2\Server\Entity\ClientEntity;
|
||||||
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
||||||
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\ScopeEntity;
|
|
||||||
use League\OAuth2\Server\Exception;
|
use League\OAuth2\Server\Exception;
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Password grant class
|
* Password grant class
|
||||||
@ -54,7 +49,7 @@ class PasswordGrant extends AbstractGrant
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the callback to verify a user's username and password
|
* Set the callback to verify a user's username and password
|
||||||
* @param callable $callback The callback function
|
* @param callable $callback The callback function
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setVerifyCredentialsCallback(callable $callback)
|
public function setVerifyCredentialsCallback(callable $callback)
|
||||||
|
@ -12,15 +12,10 @@
|
|||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
use League\OAuth2\Server\Request;
|
use League\OAuth2\Server\Request;
|
||||||
use League\OAuth2\Server\AuthorizationServer;
|
|
||||||
use League\OAuth2\Server\Exception;
|
use League\OAuth2\Server\Exception;
|
||||||
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;
|
|
||||||
use League\OAuth2\Server\Entity\RefreshTokenEntity;
|
use League\OAuth2\Server\Entity\RefreshTokenEntity;
|
||||||
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
||||||
use League\OAuth2\Server\Entity\SessionEntity;
|
|
||||||
use League\OAuth2\Server\Entity\ClientEntity;
|
use League\OAuth2\Server\Entity\ClientEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +36,7 @@ class RefreshTokenGrant extends AbstractGrant
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the TTL of the refresh token
|
* Set the TTL of the refresh token
|
||||||
* @param int $refreshTokenTTL
|
* @param int $refreshTokenTTL
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setRefreshTokenTTL($refreshTokenTTL)
|
public function setRefreshTokenTTL($refreshTokenTTL)
|
||||||
|
@ -11,10 +11,8 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server;
|
namespace League\OAuth2\Server;
|
||||||
|
|
||||||
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\SessionInterface;
|
use League\OAuth2\Server\Storage\SessionInterface;
|
||||||
use League\OAuth2\Server\Storage\ScopeInterface;
|
use League\OAuth2\Server\Storage\ScopeInterface;
|
||||||
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
||||||
@ -39,10 +37,10 @@ class ResourceServer extends AbstractServer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise the resource server
|
* Initialise the resource server
|
||||||
* @param SessionInterface $sessionStorage
|
* @param SessionInterface $sessionStorage
|
||||||
* @param AccessTokenInteface $accessTokenStorage
|
* @param AccessTokenInteface $accessTokenStorage
|
||||||
* @param ClientInterface $clientStorage
|
* @param ClientInterface $clientStorage
|
||||||
* @param ScopeInterface $scopeStorage
|
* @param ScopeInterface $scopeStorage
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
@ -68,14 +66,15 @@ class ResourceServer extends AbstractServer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the storage
|
* Set the storage
|
||||||
* @param string $type Storage type
|
* @param string $type Storage type
|
||||||
* @param mixed $storage Storage class
|
* @param mixed $storage Storage class
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
protected function setStorage($type, $storage)
|
protected function setStorage($type, $storage)
|
||||||
{
|
{
|
||||||
$storage->setServer($this);
|
$storage->setServer($this);
|
||||||
$this->storages[$type] = $storage;
|
$this->storages[$type] = $storage;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +95,7 @@ class ResourceServer extends AbstractServer
|
|||||||
public function setTokenKey($key)
|
public function setTokenKey($key)
|
||||||
{
|
{
|
||||||
$this->tokenKey = $key;
|
$this->tokenKey = $key;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +146,8 @@ class ResourceServer extends AbstractServer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the presented access token has the given scope(s)
|
* Checks if the presented access token has the given scope(s)
|
||||||
* @param array|string $scopes An array of scopes or a single scope as a string
|
* @param array|string $scopes An array of scopes or a single scope as a string
|
||||||
* @return bool Returns bool if all scopes are found, false if any fail
|
* @return bool Returns bool if all scopes are found, false if any fail
|
||||||
*/
|
*/
|
||||||
public function hasScope($scopes)
|
public function hasScope($scopes)
|
||||||
{
|
{
|
||||||
@ -162,6 +162,7 @@ class ResourceServer extends AbstractServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,13 +177,14 @@ class ResourceServer extends AbstractServer
|
|||||||
|
|
||||||
// Set the access token
|
// Set the access token
|
||||||
$this->accessToken = $this->storages['access_token']->get($accessTokenString);
|
$this->accessToken = $this->storages['access_token']->get($accessTokenString);
|
||||||
|
|
||||||
return ($this->accessToken instanceof AccessTokenEntity);
|
return ($this->accessToken instanceof AccessTokenEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads in the access token from the headers
|
* Reads in the access token from the headers
|
||||||
* @param $headersOnly Limit Access Token to Authorization header only
|
* @param $headersOnly Limit Access Token to Authorization header only
|
||||||
* @throws Exception\MissingAccessTokenException Thrown if there is no access token presented
|
* @throws Exception\MissingAccessTokenException Thrown if there is no access token presented
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function determineAccessToken($headersOnly = false)
|
public function determineAccessToken($headersOnly = false)
|
||||||
|
@ -14,7 +14,6 @@ namespace League\OAuth2\Server\Storage;
|
|||||||
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
use League\OAuth2\Server\Entity\AccessTokenEntity;
|
||||||
use League\OAuth2\Server\Entity\AbstractTokenEntity;
|
use League\OAuth2\Server\Entity\AbstractTokenEntity;
|
||||||
use League\OAuth2\Server\Entity\RefreshTokenEntity;
|
use League\OAuth2\Server\Entity\RefreshTokenEntity;
|
||||||
use League\OAuth2\Server\Entity\AuthCodeEntity;
|
|
||||||
use League\OAuth2\Server\Entity\ScopeEntity;
|
use League\OAuth2\Server\Entity\ScopeEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,14 +23,14 @@ interface AccessTokenInterface
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get an instance of Entity\AccessTokenEntity
|
* Get an instance of Entity\AccessTokenEntity
|
||||||
* @param string $token The access token
|
* @param string $token The access token
|
||||||
* @return \League\OAuth2\Server\Entity\AccessTokenEntity
|
* @return \League\OAuth2\Server\Entity\AccessTokenEntity
|
||||||
*/
|
*/
|
||||||
public function get($token);
|
public function get($token);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the access token associated with an access token
|
* Get the access token associated with an access token
|
||||||
* @param \League\OAuth2\Server\Entity\RefreshTokenEntity $refreshToken
|
* @param \League\OAuth2\Server\Entity\RefreshTokenEntity $refreshToken
|
||||||
* @return \League\OAuth2\Server\Entity\AccessTokenEntity
|
* @return \League\OAuth2\Server\Entity\AccessTokenEntity
|
||||||
*/
|
*/
|
||||||
public function getByRefreshToken(RefreshTokenEntity $refreshToken);
|
public function getByRefreshToken(RefreshTokenEntity $refreshToken);
|
||||||
@ -39,15 +38,15 @@ interface AccessTokenInterface
|
|||||||
/**
|
/**
|
||||||
* Get the scopes for an access token
|
* Get the scopes for an access token
|
||||||
* @param \League\OAuth2\Server\Entity\AbstractTokenEntity $token The access token
|
* @param \League\OAuth2\Server\Entity\AbstractTokenEntity $token The access token
|
||||||
* @return array Array of \League\OAuth2\Server\Entity\ScopeEntity
|
* @return array Array of \League\OAuth2\Server\Entity\ScopeEntity
|
||||||
*/
|
*/
|
||||||
public function getScopes(AbstractTokenEntity $token);
|
public function getScopes(AbstractTokenEntity $token);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new access token
|
* Creates a new access token
|
||||||
* @param string $token The access token
|
* @param string $token The access token
|
||||||
* @param integer $expireTime The expire time expressed as a unix timestamp
|
* @param integer $expireTime The expire time expressed as a unix timestamp
|
||||||
* @param string|integer $sessionId The session ID
|
* @param string|integer $sessionId The session ID
|
||||||
* @return \League\OAuth2\Server\Entity\AccessToken
|
* @return \League\OAuth2\Server\Entity\AccessToken
|
||||||
*/
|
*/
|
||||||
public function create($token, $expireTime, $sessionId);
|
public function create($token, $expireTime, $sessionId);
|
||||||
@ -55,7 +54,7 @@ interface AccessTokenInterface
|
|||||||
/**
|
/**
|
||||||
* Associate a scope with an acess token
|
* Associate a scope with an acess token
|
||||||
* @param \League\OAuth2\Server\Entity\AbstractTokenEntity $token The access token
|
* @param \League\OAuth2\Server\Entity\AbstractTokenEntity $token The access token
|
||||||
* @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope
|
* @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function associateScope(AbstractTokenEntity $token, ScopeEntity $scope);
|
public function associateScope(AbstractTokenEntity $token, ScopeEntity $scope);
|
||||||
|
@ -31,6 +31,7 @@ class Adapter
|
|||||||
public function setServer(AbstractServer $server)
|
public function setServer(AbstractServer $server)
|
||||||
{
|
{
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ interface AuthCodeInterface
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the auth code
|
* Get the auth code
|
||||||
* @param string $code
|
* @param string $code
|
||||||
* @return \League\OAuth2\Server\Entity\AuthCodeEntity
|
* @return \League\OAuth2\Server\Entity\AuthCodeEntity
|
||||||
*/
|
*/
|
||||||
public function get($code);
|
public function get($code);
|
||||||
|
@ -20,10 +20,10 @@ interface ClientInterface
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Validate a client
|
* Validate a client
|
||||||
* @param string $clientId The client's ID
|
* @param string $clientId The client's ID
|
||||||
* @param string $clientSecret The client's secret (default = "null")
|
* @param string $clientSecret The client's secret (default = "null")
|
||||||
* @param string $redirectUri The client's redirect URI (default = "null")
|
* @param string $redirectUri The client's redirect URI (default = "null")
|
||||||
* @param string $grantType The grant type used in the request (default = "null")
|
* @param string $grantType The grant type used in the request (default = "null")
|
||||||
* @return League\OAuth2\Server\Entity\ClientEntity
|
* @return League\OAuth2\Server\Entity\ClientEntity
|
||||||
*/
|
*/
|
||||||
public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null);
|
public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null);
|
||||||
|
@ -20,16 +20,16 @@ interface RefreshTokenInterface
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Return a new instance of \League\OAuth2\Server\Entity\RefreshTokenEntity
|
* Return a new instance of \League\OAuth2\Server\Entity\RefreshTokenEntity
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @return \League\OAuth2\Server\Entity\RefreshTokenEntity
|
* @return \League\OAuth2\Server\Entity\RefreshTokenEntity
|
||||||
*/
|
*/
|
||||||
public function get($token);
|
public function get($token);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new refresh token_name
|
* Create a new refresh token_name
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @param integer $expireTime
|
* @param integer $expireTime
|
||||||
* @param string $accessToken
|
* @param string $accessToken
|
||||||
* @return \League\OAuth2\Server\Entity\RefreshTokenEntity
|
* @return \League\OAuth2\Server\Entity\RefreshTokenEntity
|
||||||
*/
|
*/
|
||||||
public function create($token, $expireTime, $accessToken);
|
public function create($token, $expireTime, $accessToken);
|
||||||
|
@ -25,8 +25,8 @@ interface ScopeInterface
|
|||||||
* SELECT * FROM oauth_scopes WHERE scope = :scope
|
* SELECT * FROM oauth_scopes WHERE scope = :scope
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param string $scope The scope
|
* @param string $scope The scope
|
||||||
* @param string $grantType The grant type used in the request (default = "null")
|
* @param string $grantType The grant type used in the request (default = "null")
|
||||||
* @return \League\OAuth2\Server\Entity\ScopeEntity
|
* @return \League\OAuth2\Server\Entity\ScopeEntity
|
||||||
*/
|
*/
|
||||||
public function get($scope, $grantType = null);
|
public function get($scope, $grantType = null);
|
||||||
|
@ -23,7 +23,7 @@ interface SessionInterface
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get a session from it's identifier
|
* Get a session from it's identifier
|
||||||
* @param string $sessionId
|
* @param string $sessionId
|
||||||
* @return \League\OAuth2\Server\Entity\SessionEntity
|
* @return \League\OAuth2\Server\Entity\SessionEntity
|
||||||
*/
|
*/
|
||||||
public function get($sessionId);
|
public function get($sessionId);
|
||||||
@ -51,10 +51,10 @@ interface SessionInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new session
|
* Create a new session
|
||||||
* @param string $ownerType Session owner's type (user, client)
|
* @param string $ownerType Session owner's type (user, client)
|
||||||
* @param string $ownerId Session owner's ID
|
* @param string $ownerId Session owner's ID
|
||||||
* @param string $clientId Client ID
|
* @param string $clientId Client ID
|
||||||
* @param string $clientRedirectUri Client redirect URI (default = null)
|
* @param string $clientRedirectUri Client redirect URI (default = null)
|
||||||
* @return integer The session's ID
|
* @return integer The session's ID
|
||||||
*/
|
*/
|
||||||
public function create($ownerType, $ownerId, $clientId, $clientRedirectUri = null);
|
public function create($ownerType, $ownerId, $clientId, $clientRedirectUri = null);
|
||||||
@ -62,7 +62,7 @@ interface SessionInterface
|
|||||||
/**
|
/**
|
||||||
* Associate a scope with a session
|
* Associate a scope with a session
|
||||||
* @param \League\OAuth2\Server\Entity\SessionEntity $scope The scope
|
* @param \League\OAuth2\Server\Entity\SessionEntity $scope The scope
|
||||||
* @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope
|
* @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function associateScope(SessionEntity $session, ScopeEntity $scope);
|
public function associateScope(SessionEntity $session, ScopeEntity $scope);
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Util\KeyAlgorithm;
|
namespace League\OAuth2\Server\Util\KeyAlgorithm;
|
||||||
|
|
||||||
|
|
||||||
class DefaultAlgorithm implements KeyAlgorithmInterface
|
class DefaultAlgorithm implements KeyAlgorithmInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -16,16 +16,17 @@ namespace League\OAuth2\Server\Util;
|
|||||||
*/
|
*/
|
||||||
class RedirectUri
|
class RedirectUri
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Generate a new redirect uri
|
* Generate a new redirect uri
|
||||||
* @param string $uri The base URI
|
* @param string $uri The base URI
|
||||||
* @param array $params The query string parameters
|
* @param array $params The query string parameters
|
||||||
* @param string $queryDelimeter The query string delimeter (default: "?")
|
* @param string $queryDelimeter The query string delimeter (default: "?")
|
||||||
* @return string The updated URI
|
* @return string The updated URI
|
||||||
*/
|
*/
|
||||||
public static function make($uri, $params = array(), $queryDelimeter = '?')
|
public static function make($uri, $params = array(), $queryDelimeter = '?')
|
||||||
{
|
{
|
||||||
$uri .= (strstr($uri, $queryDelimeter) === false) ? $queryDelimeter : '&';
|
$uri .= (strstr($uri, $queryDelimeter) === false) ? $queryDelimeter : '&';
|
||||||
|
|
||||||
return $uri.http_build_query($params);
|
return $uri.http_build_query($params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user