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