mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-15 17:58:56 +05:30
Numerous updates
This commit is contained in:
parent
a2db7e1929
commit
11e0b004bd
@ -11,6 +11,7 @@
|
||||
|
||||
namespace League\OAuth2\Server;
|
||||
|
||||
use League\OAuth2\Server\Exception;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
@ -64,8 +65,8 @@ abstract class AbstractServer
|
||||
public function getStorage($obj)
|
||||
{
|
||||
if (!isset($this->storages[$obj])) {
|
||||
throw new ServerException(
|
||||
'The `'.$obj.'` storage interface has not been registered with the authorization server'
|
||||
throw new Exception\ServerException(
|
||||
'The `'.$obj.'` storage interface has not been registered with the server'
|
||||
);
|
||||
}
|
||||
return $this->storages[$obj];
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace League\OAuth2\Server\Grant;
|
||||
|
||||
use League\OAuth2\Server\Authorization;
|
||||
use League\OAuth2\Server\Entities\Scope;
|
||||
use League\OAuth2\Server\Entity\Scope;
|
||||
|
||||
/**
|
||||
* Abstract grant class
|
||||
@ -149,7 +149,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
||||
|
||||
/**
|
||||
* Format the local scopes array
|
||||
* @param array $unformated Array of Array of \League\OAuth2\Server\Entities\Scope
|
||||
* @param array $unformated Array of Array of \League\OAuth2\Server\Entity\Scope
|
||||
* @return array
|
||||
*/
|
||||
protected function formatScopes($unformated = [])
|
||||
|
@ -12,10 +12,10 @@
|
||||
namespace League\OAuth2\Server\Grant;
|
||||
|
||||
use League\OAuth2\Server\Authorization;
|
||||
use League\OAuth2\Server\Entities\AccessToken;
|
||||
use League\OAuth2\Server\Entities\Client;
|
||||
use League\OAuth2\Server\Entities\Session;
|
||||
use League\OAuth2\Server\Entities\Scope;
|
||||
use League\OAuth2\Server\Entity\AccessToken;
|
||||
use League\OAuth2\Server\Entity\Client;
|
||||
use League\OAuth2\Server\Entity\Session;
|
||||
use League\OAuth2\Server\Entity\Scope;
|
||||
use League\OAuth2\Server\Exception\ClientException;
|
||||
use League\OAuth2\Server\Util\SecureKey;
|
||||
use League\OAuth2\Server\Storage\SessionInterface;
|
||||
|
@ -12,11 +12,11 @@
|
||||
namespace League\OAuth2\Server\Grant;
|
||||
|
||||
use League\OAuth2\Server\Authorization;
|
||||
use League\OAuth2\Server\Entities\AccessToken;
|
||||
use League\OAuth2\Server\Entities\Client;
|
||||
use League\OAuth2\Server\Entities\RefreshToken;
|
||||
use League\OAuth2\Server\Entities\Session;
|
||||
use League\OAuth2\Server\Entities\Scope;
|
||||
use League\OAuth2\Server\Entity\AccessToken;
|
||||
use League\OAuth2\Server\Entity\Client;
|
||||
use League\OAuth2\Server\Entity\RefreshToken;
|
||||
use League\OAuth2\Server\Entity\Session;
|
||||
use League\OAuth2\Server\Entity\Scope;
|
||||
use League\OAuth2\Server\Exception\ClientException;
|
||||
use League\OAuth2\Server\Exception\InvalidGrantTypeException;
|
||||
use League\OAuth2\Server\Util\SecureKey;
|
||||
|
@ -18,9 +18,9 @@ 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\Entities\RefreshToken as RT;
|
||||
use League\OAuth2\Server\Entities\AccessToken;
|
||||
use League\OAuth2\Server\Entities\Session;
|
||||
use League\OAuth2\Server\Entity\RefreshToken as RT;
|
||||
use League\OAuth2\Server\Entity\AccessToken;
|
||||
use League\OAuth2\Server\Entity\Session;
|
||||
use League\OAuth2\Server\Exception\ClientException;
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@ 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\AccessToken;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
@ -28,7 +29,7 @@ class Resource extends AbstractServer
|
||||
* The access token
|
||||
* @var League\OAuth2\Server\AccessToken
|
||||
*/
|
||||
protected $accessToken;
|
||||
public $accessToken;
|
||||
|
||||
/**
|
||||
* The query string key which is used by clients to present the access token (default: access_token)
|
||||
@ -77,7 +78,7 @@ class Resource extends AbstractServer
|
||||
*/
|
||||
public function getTokenKey()
|
||||
{
|
||||
return $this->accessToken->getToken();
|
||||
return $this->tokenKey;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,13 +137,12 @@ class Resource extends AbstractServer
|
||||
{
|
||||
try {
|
||||
$accessTokenString = $this->determineAccessToken($headersOnly);
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the access token
|
||||
$this->accessToken = $this->storages['access_token']->get($accessTokenString);
|
||||
|
||||
return ($this->accessToken instanceof AccessToken);
|
||||
}
|
||||
|
||||
@ -162,7 +162,18 @@ class Resource extends AbstractServer
|
||||
*/
|
||||
public function hasScope($scopes)
|
||||
{
|
||||
return $this->accessToken->hasScope($scopes);
|
||||
if (is_string($scopes)) {
|
||||
return $this->accessToken->hasScope($scopes);
|
||||
}
|
||||
|
||||
if (is_array($scopes)) {
|
||||
foreach ($scopes as $scope) {
|
||||
if (!$this->accessToken->hasScope($scope)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ interface AccessTokenInterface
|
||||
/**
|
||||
* Get an instance of Entites\AccessToken
|
||||
* @param string $token The access token
|
||||
* @return \League\OAuth2\Server\Entities\AccessToken
|
||||
* @return \League\OAuth2\Server\Entity\AccessToken
|
||||
*/
|
||||
public function get($token);
|
||||
|
||||
@ -28,7 +28,7 @@ interface AccessTokenInterface
|
||||
/**
|
||||
* Get the scopes for an access token
|
||||
* @param string $token The access token
|
||||
* @return array Array of \League\OAuth2\Server\Entities\Scope
|
||||
* @return array Array of \League\OAuth2\Server\Entity\Scope
|
||||
*/
|
||||
public function getScopes($token);
|
||||
|
||||
@ -37,7 +37,7 @@ interface AccessTokenInterface
|
||||
* @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\Entities\AccessToken
|
||||
* @return \League\OAuth2\Server\Entity\AccessToken
|
||||
*/
|
||||
public function create($token, $expireTime, $sessionId);
|
||||
|
||||
|
@ -18,13 +18,13 @@ class Adapter
|
||||
{
|
||||
/**
|
||||
* Server
|
||||
* @var \League\OAuth2\Server\Authorization|\League\OAuth2\Server\Resource $server
|
||||
* @var \League\OAuth2\Server\AbstractServer $server
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* Set the server
|
||||
* @param \League\OAuth2\Server\Authorization|\League\OAuth2\Server\Resource $server
|
||||
* @param \League\OAuth2\Server\AbstractServer $server
|
||||
*/
|
||||
public function setServer($server)
|
||||
{
|
||||
@ -34,7 +34,7 @@ class Adapter
|
||||
|
||||
/**
|
||||
* Return the server
|
||||
* @return \League\OAuth2\Server\Authorization|\League\OAuth2\Server\Resource
|
||||
* @return \League\OAuth2\Server\AbstractServer
|
||||
*/
|
||||
protected function getServer()
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ interface AuthCodeInterface
|
||||
/**
|
||||
* Get the auth code
|
||||
* @param string $code
|
||||
* @return \League\OAuth2\Server\Entities\AuthCode
|
||||
* @return \League\OAuth2\Server\Entity\AuthCode
|
||||
*/
|
||||
public function get($code);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ interface ClientInterface
|
||||
* @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\Entities\Client|null
|
||||
* @return League\OAuth2\Server\Entity\Client|null
|
||||
*/
|
||||
public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null);
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ namespace League\OAuth2\Server\Storage;
|
||||
interface RefreshTokenInterface
|
||||
{
|
||||
/**
|
||||
* Return a new instance of \League\OAuth2\Server\Entities\RefreshToken
|
||||
* Return a new instance of \League\OAuth2\Server\Entity\RefreshToken
|
||||
* @param string $token
|
||||
* @return \League\OAuth2\Server\Entities\RefreshToken
|
||||
* @return \League\OAuth2\Server\Entity\RefreshToken
|
||||
*/
|
||||
public function get($token);
|
||||
|
||||
@ -28,7 +28,7 @@ interface RefreshTokenInterface
|
||||
* @param string $token
|
||||
* @param integer $expireTime
|
||||
* @param string $accessToken
|
||||
* @return \League\OAuth2\Server\Entities\RefreshToken
|
||||
* @return \League\OAuth2\Server\Entity\RefreshToken
|
||||
*/
|
||||
public function create($token, $expireTime, $accessToken);
|
||||
|
||||
|
@ -19,21 +19,21 @@ interface SessionInterface
|
||||
/**
|
||||
* Get a session from it's identifier
|
||||
* @param string $sessionId
|
||||
* @return \League\OAuth2\Server\Entities\Session
|
||||
* @return \League\OAuth2\Server\Entity\Session
|
||||
*/
|
||||
public function get($sessionId);
|
||||
|
||||
/**
|
||||
* Get a session from an access token
|
||||
* @param string $accessToken The access token
|
||||
* @return \League\OAuth2\Server\Entities\Session
|
||||
* @return \League\OAuth2\Server\Entity\Session
|
||||
*/
|
||||
public function getByAccessToken($accessToken);
|
||||
|
||||
/**
|
||||
* Get a session's scopes
|
||||
* @param integer $sessionId
|
||||
* @return array Array of \League\OAuth2\Server\Entities\Scope
|
||||
* @return array Array of \League\OAuth2\Server\Entity\Scope
|
||||
*/
|
||||
public function getScopes($sessionId);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user