mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-01 16:33:07 +05:30
commit
46cd448a47
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server;
|
namespace League\OAuth2\Server;
|
||||||
|
|
||||||
use DateInterval;
|
|
||||||
use League\Event\EmitterAwareInterface;
|
use League\Event\EmitterAwareInterface;
|
||||||
use League\Event\EmitterAwareTrait;
|
use League\Event\EmitterAwareTrait;
|
||||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||||
@ -28,7 +27,7 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
use EmitterAwareTrait;
|
use EmitterAwareTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\Grant\GrantTypeInterface[]
|
* @var GrantTypeInterface[]
|
||||||
*/
|
*/
|
||||||
protected $enabledGrantTypes = [];
|
protected $enabledGrantTypes = [];
|
||||||
|
|
||||||
@ -38,44 +37,44 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
protected $grantTypeAccessTokenTTL = [];
|
protected $grantTypeAccessTokenTTL = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\CryptKey
|
* @var CryptKey
|
||||||
*/
|
*/
|
||||||
protected $privateKey;
|
protected $privateKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\CryptKey
|
* @var CryptKey
|
||||||
*/
|
*/
|
||||||
protected $publicKey;
|
protected $publicKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ResponseTypeInterface
|
* @var null|ResponseTypeInterface
|
||||||
*/
|
*/
|
||||||
protected $responseType;
|
protected $responseType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\Repositories\ClientRepositoryInterface
|
* @var ClientRepositoryInterface
|
||||||
*/
|
*/
|
||||||
private $clientRepository;
|
private $clientRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface
|
* @var AccessTokenRepositoryInterface
|
||||||
*/
|
*/
|
||||||
private $accessTokenRepository;
|
private $accessTokenRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\Repositories\ScopeRepositoryInterface
|
* @var ScopeRepositoryInterface
|
||||||
*/
|
*/
|
||||||
private $scopeRepository;
|
private $scopeRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New server instance.
|
* New server instance.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Repositories\ClientRepositoryInterface $clientRepository
|
* @param ClientRepositoryInterface $clientRepository
|
||||||
* @param \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface $accessTokenRepository
|
* @param AccessTokenRepositoryInterface $accessTokenRepository
|
||||||
* @param \League\OAuth2\Server\Repositories\ScopeRepositoryInterface $scopeRepository
|
* @param ScopeRepositoryInterface $scopeRepository
|
||||||
* @param \League\OAuth2\Server\CryptKey|string $privateKey
|
* @param CryptKey|string $privateKey
|
||||||
* @param \League\OAuth2\Server\CryptKey|string $publicKey
|
* @param CryptKey|string $publicKey
|
||||||
* @param null|\League\OAuth2\Server\ResponseTypes\ResponseTypeInterface $responseType
|
* @param null|ResponseTypeInterface $responseType
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ClientRepositoryInterface $clientRepository,
|
ClientRepositoryInterface $clientRepository,
|
||||||
@ -89,12 +88,12 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
$this->accessTokenRepository = $accessTokenRepository;
|
$this->accessTokenRepository = $accessTokenRepository;
|
||||||
$this->scopeRepository = $scopeRepository;
|
$this->scopeRepository = $scopeRepository;
|
||||||
|
|
||||||
if (!$privateKey instanceof CryptKey) {
|
if ($privateKey instanceof CryptKey === false) {
|
||||||
$privateKey = new CryptKey($privateKey);
|
$privateKey = new CryptKey($privateKey);
|
||||||
}
|
}
|
||||||
$this->privateKey = $privateKey;
|
$this->privateKey = $privateKey;
|
||||||
|
|
||||||
if (!$publicKey instanceof CryptKey) {
|
if ($publicKey instanceof CryptKey === false) {
|
||||||
$publicKey = new CryptKey($publicKey);
|
$publicKey = new CryptKey($publicKey);
|
||||||
}
|
}
|
||||||
$this->publicKey = $publicKey;
|
$this->publicKey = $publicKey;
|
||||||
@ -105,12 +104,12 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
/**
|
/**
|
||||||
* Enable a grant type on the server.
|
* Enable a grant type on the server.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Grant\GrantTypeInterface $grantType
|
* @param GrantTypeInterface $grantType
|
||||||
* @param \DateInterval $accessTokenTTL
|
* @param null|\DateInterval $accessTokenTTL
|
||||||
*/
|
*/
|
||||||
public function enableGrantType(GrantTypeInterface $grantType, DateInterval $accessTokenTTL = null)
|
public function enableGrantType(GrantTypeInterface $grantType, \DateInterval $accessTokenTTL = null)
|
||||||
{
|
{
|
||||||
if ($accessTokenTTL instanceof DateInterval === false) {
|
if ($accessTokenTTL instanceof \DateInterval === false) {
|
||||||
$accessTokenTTL = new \DateInterval('PT1H');
|
$accessTokenTTL = new \DateInterval('PT1H');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,11 +127,11 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
/**
|
/**
|
||||||
* Validate an authorization request
|
* Validate an authorization request
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
*
|
*
|
||||||
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
* @throws OAuthServerException
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\RequestTypes\AuthorizationRequest|null
|
* @return AuthorizationRequest
|
||||||
*/
|
*/
|
||||||
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
@ -153,10 +152,10 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
/**
|
/**
|
||||||
* Complete an authorization request
|
* Complete an authorization request
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\RequestTypes\AuthorizationRequest $authRequest
|
* @param AuthorizationRequest $authRequest
|
||||||
* @param \Psr\Http\Message\ResponseInterface $response
|
* @param ResponseInterface $response
|
||||||
*
|
*
|
||||||
* @return \Psr\Http\Message\ResponseInterface
|
* @return ResponseInterface
|
||||||
*/
|
*/
|
||||||
public function completeAuthorizationRequest(AuthorizationRequest $authRequest, ResponseInterface $response)
|
public function completeAuthorizationRequest(AuthorizationRequest $authRequest, ResponseInterface $response)
|
||||||
{
|
{
|
||||||
@ -168,12 +167,12 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
/**
|
/**
|
||||||
* Return an access token response.
|
* Return an access token response.
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param \Psr\Http\Message\ResponseInterface $response
|
* @param ResponseInterface $response
|
||||||
*
|
*
|
||||||
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
* @throws OAuthServerException
|
||||||
*
|
*
|
||||||
* @return \Psr\Http\Message\ResponseInterface
|
* @return ResponseInterface
|
||||||
*/
|
*/
|
||||||
public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response)
|
public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response)
|
||||||
{
|
{
|
||||||
@ -203,7 +202,7 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
*/
|
*/
|
||||||
protected function getResponseType()
|
protected function getResponseType()
|
||||||
{
|
{
|
||||||
if (!$this->responseType instanceof ResponseTypeInterface) {
|
if ($this->responseType instanceof ResponseTypeInterface === false) {
|
||||||
$this->responseType = new BearerTokenResponse();
|
$this->responseType = new BearerTokenResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,14 +22,12 @@ class BearerTokenValidator implements AuthorizationValidatorInterface
|
|||||||
use CryptTrait;
|
use CryptTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface
|
* @var AccessTokenRepositoryInterface
|
||||||
*/
|
*/
|
||||||
private $accessTokenRepository;
|
private $accessTokenRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BearerTokenValidator constructor.
|
* @param AccessTokenRepositoryInterface $accessTokenRepository
|
||||||
*
|
|
||||||
* @param \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface $accessTokenRepository
|
|
||||||
*/
|
*/
|
||||||
public function __construct(AccessTokenRepositoryInterface $accessTokenRepository)
|
public function __construct(AccessTokenRepositoryInterface $accessTokenRepository)
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server;
|
namespace League\OAuth2\Server;
|
||||||
|
|
||||||
class CryptKey
|
class CryptKey
|
||||||
@ -18,7 +19,7 @@ class CryptKey
|
|||||||
protected $keyPath;
|
protected $keyPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var null|string
|
||||||
*/
|
*/
|
||||||
protected $passPhrase;
|
protected $passPhrase;
|
||||||
|
|
||||||
|
@ -8,24 +8,25 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server;
|
namespace League\OAuth2\Server;
|
||||||
|
|
||||||
trait CryptTrait
|
trait CryptTrait
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\CryptKey
|
* @var CryptKey
|
||||||
*/
|
*/
|
||||||
protected $privateKey;
|
protected $privateKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\CryptKey
|
* @var CryptKey
|
||||||
*/
|
*/
|
||||||
protected $publicKey;
|
protected $publicKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set path to private key.
|
* Set path to private key.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\CryptKey $privateKey
|
* @param CryptKey $privateKey
|
||||||
*/
|
*/
|
||||||
public function setPrivateKey(CryptKey $privateKey)
|
public function setPrivateKey(CryptKey $privateKey)
|
||||||
{
|
{
|
||||||
@ -35,7 +36,7 @@ trait CryptTrait
|
|||||||
/**
|
/**
|
||||||
* Set path to public key.
|
* Set path to public key.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\CryptKey $publicKey
|
* @param CryptKey $publicKey
|
||||||
*/
|
*/
|
||||||
public function setPublicKey(CryptKey $publicKey)
|
public function setPublicKey(CryptKey $publicKey)
|
||||||
{
|
{
|
||||||
@ -47,6 +48,8 @@ trait CryptTrait
|
|||||||
*
|
*
|
||||||
* @param string $unencryptedData
|
* @param string $unencryptedData
|
||||||
*
|
*
|
||||||
|
* @throws \LogicException
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function encrypt($unencryptedData)
|
protected function encrypt($unencryptedData)
|
||||||
|
@ -16,7 +16,7 @@ interface AccessTokenEntityInterface extends TokenInterface
|
|||||||
/**
|
/**
|
||||||
* Generate a JWT from the access token
|
* Generate a JWT from the access token
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\CryptKey $privateKey
|
* @param CryptKey $privateKey
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -42,14 +42,14 @@ interface RefreshTokenEntityInterface
|
|||||||
/**
|
/**
|
||||||
* Set the access token that the refresh token was associated with.
|
* Set the access token that the refresh token was associated with.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Entities\AccessTokenEntityInterface $accessToken
|
* @param AccessTokenEntityInterface $accessToken
|
||||||
*/
|
*/
|
||||||
public function setAccessToken(AccessTokenEntityInterface $accessToken);
|
public function setAccessToken(AccessTokenEntityInterface $accessToken);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the access token that the refresh token was originally associated with.
|
* Get the access token that the refresh token was originally associated with.
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\Entities\AccessTokenEntityInterface
|
* @return AccessTokenEntityInterface
|
||||||
*/
|
*/
|
||||||
public function getAccessToken();
|
public function getAccessToken();
|
||||||
}
|
}
|
||||||
|
@ -63,14 +63,14 @@ interface TokenInterface
|
|||||||
/**
|
/**
|
||||||
* Set the client that the token was issued to.
|
* Set the client that the token was issued to.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Entities\ClientEntityInterface $client
|
* @param ClientEntityInterface $client
|
||||||
*/
|
*/
|
||||||
public function setClient(ClientEntityInterface $client);
|
public function setClient(ClientEntityInterface $client);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate a scope with the token.
|
* Associate a scope with the token.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Entities\ScopeEntityInterface $scope
|
* @param ScopeEntityInterface $scope
|
||||||
*/
|
*/
|
||||||
public function addScope(ScopeEntityInterface $scope);
|
public function addScope(ScopeEntityInterface $scope);
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ trait AccessTokenTrait
|
|||||||
/**
|
/**
|
||||||
* Generate a JWT from the access token
|
* Generate a JWT from the access token
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\CryptKey $privateKey
|
* @param CryptKey $privateKey
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -11,8 +11,14 @@ namespace League\OAuth2\Server\Entities\Traits;
|
|||||||
|
|
||||||
trait ClientTrait
|
trait ClientTrait
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $name;
|
protected $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string|string[]
|
||||||
|
*/
|
||||||
protected $redirectUri;
|
protected $redirectUri;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Entities\Traits;
|
namespace League\OAuth2\Server\Entities\Traits;
|
||||||
|
|
||||||
use DateTime;
|
|
||||||
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
||||||
|
|
||||||
trait RefreshTokenTrait
|
trait RefreshTokenTrait
|
||||||
@ -20,7 +19,7 @@ trait RefreshTokenTrait
|
|||||||
protected $accessToken;
|
protected $accessToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DateTime
|
* @var \DateTime
|
||||||
*/
|
*/
|
||||||
protected $expiryDateTime;
|
protected $expiryDateTime;
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ trait RefreshTokenTrait
|
|||||||
/**
|
/**
|
||||||
* Get the token's expiry date time.
|
* Get the token's expiry date time.
|
||||||
*
|
*
|
||||||
* @return DateTime
|
* @return \DateTime
|
||||||
*/
|
*/
|
||||||
public function getExpiryDateTime()
|
public function getExpiryDateTime()
|
||||||
{
|
{
|
||||||
@ -53,9 +52,9 @@ trait RefreshTokenTrait
|
|||||||
/**
|
/**
|
||||||
* Set the date time when the token expires.
|
* Set the date time when the token expires.
|
||||||
*
|
*
|
||||||
* @param DateTime $dateTime
|
* @param \DateTime $dateTime
|
||||||
*/
|
*/
|
||||||
public function setExpiryDateTime(DateTime $dateTime)
|
public function setExpiryDateTime(\DateTime $dateTime)
|
||||||
{
|
{
|
||||||
$this->expiryDateTime = $dateTime;
|
$this->expiryDateTime = $dateTime;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Entities\Traits;
|
namespace League\OAuth2\Server\Entities\Traits;
|
||||||
|
|
||||||
use DateTime;
|
|
||||||
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
||||||
use League\OAuth2\Server\Entities\ScopeEntityInterface;
|
use League\OAuth2\Server\Entities\ScopeEntityInterface;
|
||||||
|
|
||||||
@ -21,7 +20,7 @@ trait TokenEntityTrait
|
|||||||
protected $scopes = [];
|
protected $scopes = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DateTime
|
* @var \DateTime
|
||||||
*/
|
*/
|
||||||
protected $expiryDateTime;
|
protected $expiryDateTime;
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ trait TokenEntityTrait
|
|||||||
/**
|
/**
|
||||||
* Associate a scope with the token.
|
* Associate a scope with the token.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Entities\ScopeEntityInterface $scope
|
* @param ScopeEntityInterface $scope
|
||||||
*/
|
*/
|
||||||
public function addScope(ScopeEntityInterface $scope)
|
public function addScope(ScopeEntityInterface $scope)
|
||||||
{
|
{
|
||||||
@ -58,7 +57,7 @@ trait TokenEntityTrait
|
|||||||
/**
|
/**
|
||||||
* Get the token's expiry date time.
|
* Get the token's expiry date time.
|
||||||
*
|
*
|
||||||
* @return DateTime
|
* @return \DateTime
|
||||||
*/
|
*/
|
||||||
public function getExpiryDateTime()
|
public function getExpiryDateTime()
|
||||||
{
|
{
|
||||||
@ -68,9 +67,9 @@ trait TokenEntityTrait
|
|||||||
/**
|
/**
|
||||||
* Set the date time when the token expires.
|
* Set the date time when the token expires.
|
||||||
*
|
*
|
||||||
* @param DateTime $dateTime
|
* @param \DateTime $dateTime
|
||||||
*/
|
*/
|
||||||
public function setExpiryDateTime(DateTime $dateTime)
|
public function setExpiryDateTime(\DateTime $dateTime)
|
||||||
{
|
{
|
||||||
$this->expiryDateTime = $dateTime;
|
$this->expiryDateTime = $dateTime;
|
||||||
}
|
}
|
||||||
@ -108,7 +107,7 @@ trait TokenEntityTrait
|
|||||||
/**
|
/**
|
||||||
* Set the client that the token was issued to.
|
* Set the client that the token was issued to.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Entities\ClientEntityInterface $client
|
* @param ClientEntityInterface $client
|
||||||
*/
|
*/
|
||||||
public function setClient(ClientEntityInterface $client)
|
public function setClient(ClientEntityInterface $client)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ class OAuthServerException extends \Exception
|
|||||||
* Invalid request error.
|
* Invalid request error.
|
||||||
*
|
*
|
||||||
* @param string $parameter The invalid parameter
|
* @param string $parameter The invalid parameter
|
||||||
* @param string|null $hint
|
* @param null|string $hint
|
||||||
*
|
*
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
@ -143,7 +143,7 @@ class OAuthServerException extends \Exception
|
|||||||
/**
|
/**
|
||||||
* Invalid refresh token.
|
* Invalid refresh token.
|
||||||
*
|
*
|
||||||
* @param string|null $hint
|
* @param null|string $hint
|
||||||
*
|
*
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
@ -155,8 +155,8 @@ class OAuthServerException extends \Exception
|
|||||||
/**
|
/**
|
||||||
* Access denied.
|
* Access denied.
|
||||||
*
|
*
|
||||||
* @param string|null $hint
|
* @param null|string $hint
|
||||||
* @param string|null $redirectUri
|
* @param null|string $redirectUri
|
||||||
*
|
*
|
||||||
* @return static
|
* @return static
|
||||||
*/
|
*/
|
||||||
@ -203,11 +203,10 @@ class OAuthServerException extends \Exception
|
|||||||
/**
|
/**
|
||||||
* Generate a HTTP response.
|
* Generate a HTTP response.
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ResponseInterface $response
|
* @param ResponseInterface $response
|
||||||
* @param bool $useFragment True if errors should be in the URI fragment instead of
|
* @param bool $useFragment True if errors should be in the URI fragment instead of query string
|
||||||
* query string
|
|
||||||
*
|
*
|
||||||
* @return \Psr\Http\Message\ResponseInterface
|
* @return ResponseInterface
|
||||||
*/
|
*/
|
||||||
public function generateHttpResponse(ResponseInterface $response, $useFragment = false)
|
public function generateHttpResponse(ResponseInterface $response, $useFragment = false)
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,9 @@ namespace League\OAuth2\Server\Grant;
|
|||||||
use League\Event\EmitterAwareTrait;
|
use League\Event\EmitterAwareTrait;
|
||||||
use League\OAuth2\Server\CryptTrait;
|
use League\OAuth2\Server\CryptTrait;
|
||||||
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
||||||
|
use League\OAuth2\Server\Entities\AuthCodeEntityInterface;
|
||||||
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
||||||
|
use League\OAuth2\Server\Entities\RefreshTokenEntityInterface;
|
||||||
use League\OAuth2\Server\Entities\ScopeEntityInterface;
|
use League\OAuth2\Server\Entities\ScopeEntityInterface;
|
||||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||||
use League\OAuth2\Server\Exception\UniqueTokenIdentifierConstraintViolationException;
|
use League\OAuth2\Server\Exception\UniqueTokenIdentifierConstraintViolationException;
|
||||||
@ -54,17 +56,17 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
protected $scopeRepository;
|
protected $scopeRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface
|
* @var AuthCodeRepositoryInterface
|
||||||
*/
|
*/
|
||||||
protected $authCodeRepository;
|
protected $authCodeRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface
|
* @var RefreshTokenRepositoryInterface
|
||||||
*/
|
*/
|
||||||
protected $refreshTokenRepository;
|
protected $refreshTokenRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\Repositories\UserRepositoryInterface
|
* @var UserRepositoryInterface
|
||||||
*/
|
*/
|
||||||
protected $userRepository;
|
protected $userRepository;
|
||||||
|
|
||||||
@ -98,7 +100,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface $refreshTokenRepository
|
* @param RefreshTokenRepositoryInterface $refreshTokenRepository
|
||||||
*/
|
*/
|
||||||
public function setRefreshTokenRepository(RefreshTokenRepositoryInterface $refreshTokenRepository)
|
public function setRefreshTokenRepository(RefreshTokenRepositoryInterface $refreshTokenRepository)
|
||||||
{
|
{
|
||||||
@ -106,7 +108,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface $authCodeRepository
|
* @param AuthCodeRepositoryInterface $authCodeRepository
|
||||||
*/
|
*/
|
||||||
public function setAuthCodeRepository(AuthCodeRepositoryInterface $authCodeRepository)
|
public function setAuthCodeRepository(AuthCodeRepositoryInterface $authCodeRepository)
|
||||||
{
|
{
|
||||||
@ -114,7 +116,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \League\OAuth2\Server\Repositories\UserRepositoryInterface $userRepository
|
* @param UserRepositoryInterface $userRepository
|
||||||
*/
|
*/
|
||||||
public function setUserRepository(UserRepositoryInterface $userRepository)
|
public function setUserRepository(UserRepositoryInterface $userRepository)
|
||||||
{
|
{
|
||||||
@ -132,11 +134,11 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
/**
|
/**
|
||||||
* Validate the client.
|
* Validate the client.
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
*
|
*
|
||||||
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
* @throws OAuthServerException
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\Entities\ClientEntityInterface
|
* @return ClientEntityInterface
|
||||||
*/
|
*/
|
||||||
protected function validateClient(ServerRequestInterface $request)
|
protected function validateClient(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
@ -157,7 +159,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$client instanceof ClientEntityInterface) {
|
if ($client instanceof ClientEntityInterface === false) {
|
||||||
$this->getEmitter()->emit(new RequestEvent(RequestEvent::CLIENT_AUTHENTICATION_FAILED, $request));
|
$this->getEmitter()->emit(new RequestEvent(RequestEvent::CLIENT_AUTHENTICATION_FAILED, $request));
|
||||||
throw OAuthServerException::invalidClient();
|
throw OAuthServerException::invalidClient();
|
||||||
}
|
}
|
||||||
@ -189,9 +191,9 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
* @param string $scopes
|
* @param string $scopes
|
||||||
* @param string $redirectUri
|
* @param string $redirectUri
|
||||||
*
|
*
|
||||||
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
* @throws OAuthServerException
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\Entities\ScopeEntityInterface[]
|
* @return ScopeEntityInterface[]
|
||||||
*/
|
*/
|
||||||
public function validateScopes(
|
public function validateScopes(
|
||||||
$scopes,
|
$scopes,
|
||||||
@ -208,7 +210,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
foreach ($scopesList as $scopeItem) {
|
foreach ($scopesList as $scopeItem) {
|
||||||
$scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeItem);
|
$scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeItem);
|
||||||
|
|
||||||
if (!$scope instanceof ScopeEntityInterface) {
|
if ($scope instanceof ScopeEntityInterface === false) {
|
||||||
throw OAuthServerException::invalidScope($scopeItem, $redirectUri);
|
throw OAuthServerException::invalidScope($scopeItem, $redirectUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +224,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
* Retrieve request parameter.
|
* Retrieve request parameter.
|
||||||
*
|
*
|
||||||
* @param string $parameter
|
* @param string $parameter
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param mixed $default
|
* @param mixed $default
|
||||||
*
|
*
|
||||||
* @return null|string
|
* @return null|string
|
||||||
@ -241,7 +243,8 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
* not exist, or is otherwise an invalid HTTP Basic header, return
|
* not exist, or is otherwise an invalid HTTP Basic header, return
|
||||||
* [null, null].
|
* [null, null].
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
|
*
|
||||||
* @return string[]|null[]
|
* @return string[]|null[]
|
||||||
*/
|
*/
|
||||||
protected function getBasicAuthCredentials(ServerRequestInterface $request)
|
protected function getBasicAuthCredentials(ServerRequestInterface $request)
|
||||||
@ -270,7 +273,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
* Retrieve query string parameter.
|
* Retrieve query string parameter.
|
||||||
*
|
*
|
||||||
* @param string $parameter
|
* @param string $parameter
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param mixed $default
|
* @param mixed $default
|
||||||
*
|
*
|
||||||
* @return null|string
|
* @return null|string
|
||||||
@ -284,7 +287,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
* Retrieve cookie parameter.
|
* Retrieve cookie parameter.
|
||||||
*
|
*
|
||||||
* @param string $parameter
|
* @param string $parameter
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param mixed $default
|
* @param mixed $default
|
||||||
*
|
*
|
||||||
* @return null|string
|
* @return null|string
|
||||||
@ -298,7 +301,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
* Retrieve server parameter.
|
* Retrieve server parameter.
|
||||||
*
|
*
|
||||||
* @param string $parameter
|
* @param string $parameter
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param mixed $default
|
* @param mixed $default
|
||||||
*
|
*
|
||||||
* @return null|string
|
* @return null|string
|
||||||
@ -312,11 +315,14 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
* Issue an access token.
|
* Issue an access token.
|
||||||
*
|
*
|
||||||
* @param \DateInterval $accessTokenTTL
|
* @param \DateInterval $accessTokenTTL
|
||||||
* @param \League\OAuth2\Server\Entities\ClientEntityInterface $client
|
* @param ClientEntityInterface $client
|
||||||
* @param string $userIdentifier
|
* @param string $userIdentifier
|
||||||
* @param \League\OAuth2\Server\Entities\ScopeEntityInterface[] $scopes
|
* @param ScopeEntityInterface[] $scopes
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\Entities\AccessTokenEntityInterface
|
* @throws OAuthServerException
|
||||||
|
* @throws UniqueTokenIdentifierConstraintViolationException
|
||||||
|
*
|
||||||
|
* @return AccessTokenEntityInterface
|
||||||
*/
|
*/
|
||||||
protected function issueAccessToken(
|
protected function issueAccessToken(
|
||||||
\DateInterval $accessTokenTTL,
|
\DateInterval $accessTokenTTL,
|
||||||
@ -352,12 +358,15 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
* Issue an auth code.
|
* Issue an auth code.
|
||||||
*
|
*
|
||||||
* @param \DateInterval $authCodeTTL
|
* @param \DateInterval $authCodeTTL
|
||||||
* @param \League\OAuth2\Server\Entities\ClientEntityInterface $client
|
* @param ClientEntityInterface $client
|
||||||
* @param string $userIdentifier
|
* @param string $userIdentifier
|
||||||
* @param string $redirectUri
|
* @param string $redirectUri
|
||||||
* @param \League\OAuth2\Server\Entities\ScopeEntityInterface[] $scopes
|
* @param ScopeEntityInterface[] $scopes
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\Entities\AuthCodeEntityInterface
|
* @throws OAuthServerException
|
||||||
|
* @throws UniqueTokenIdentifierConstraintViolationException
|
||||||
|
*
|
||||||
|
* @return AuthCodeEntityInterface
|
||||||
*/
|
*/
|
||||||
protected function issueAuthCode(
|
protected function issueAuthCode(
|
||||||
\DateInterval $authCodeTTL,
|
\DateInterval $authCodeTTL,
|
||||||
@ -392,9 +401,12 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \League\OAuth2\Server\Entities\AccessTokenEntityInterface $accessToken
|
* @param AccessTokenEntityInterface $accessToken
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\Entities\RefreshTokenEntityInterface
|
* @throws OAuthServerException
|
||||||
|
* @throws UniqueTokenIdentifierConstraintViolationException
|
||||||
|
*
|
||||||
|
* @return RefreshTokenEntityInterface
|
||||||
*/
|
*/
|
||||||
protected function issueRefreshToken(AccessTokenEntityInterface $accessToken)
|
protected function issueRefreshToken(AccessTokenEntityInterface $accessToken)
|
||||||
{
|
{
|
||||||
@ -422,7 +434,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
*
|
*
|
||||||
* @param int $length
|
* @param int $length
|
||||||
*
|
*
|
||||||
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
* @throws OAuthServerException
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
use DateInterval;
|
|
||||||
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
||||||
use League\OAuth2\Server\Entities\ScopeEntityInterface;
|
use League\OAuth2\Server\Entities\ScopeEntityInterface;
|
||||||
use League\OAuth2\Server\Entities\UserEntityInterface;
|
use League\OAuth2\Server\Entities\UserEntityInterface;
|
||||||
@ -35,8 +34,8 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
private $enableCodeExchangeProof = false;
|
private $enableCodeExchangeProof = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface $authCodeRepository
|
* @param AuthCodeRepositoryInterface $authCodeRepository
|
||||||
* @param \League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface $refreshTokenRepository
|
* @param RefreshTokenRepositoryInterface $refreshTokenRepository
|
||||||
* @param \DateInterval $authCodeTTL
|
* @param \DateInterval $authCodeTTL
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
@ -58,18 +57,18 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
/**
|
/**
|
||||||
* Respond to an access token request.
|
* Respond to an access token request.
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param \League\OAuth2\Server\ResponseTypes\ResponseTypeInterface $responseType
|
* @param ResponseTypeInterface $responseType
|
||||||
* @param \DateInterval $accessTokenTTL
|
* @param \DateInterval $accessTokenTTL
|
||||||
*
|
*
|
||||||
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
* @throws OAuthServerException
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\ResponseTypes\ResponseTypeInterface
|
* @return ResponseTypeInterface
|
||||||
*/
|
*/
|
||||||
public function respondToAccessTokenRequest(
|
public function respondToAccessTokenRequest(
|
||||||
ServerRequestInterface $request,
|
ServerRequestInterface $request,
|
||||||
ResponseTypeInterface $responseType,
|
ResponseTypeInterface $responseType,
|
||||||
DateInterval $accessTokenTTL
|
\DateInterval $accessTokenTTL
|
||||||
) {
|
) {
|
||||||
// Validate request
|
// Validate request
|
||||||
$client = $this->validateClient($request);
|
$client = $this->validateClient($request);
|
||||||
@ -108,7 +107,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
foreach ($authCodePayload->scopes as $scopeId) {
|
foreach ($authCodePayload->scopes as $scopeId) {
|
||||||
$scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeId);
|
$scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeId);
|
||||||
|
|
||||||
if (!$scope instanceof ScopeEntityInterface) {
|
if ($scope instanceof ScopeEntityInterface === false) {
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
throw OAuthServerException::invalidScope($scopeId);
|
throw OAuthServerException::invalidScope($scopeId);
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
use League\OAuth2\Server\ResponseTypes\ResponseTypeInterface;
|
use League\OAuth2\Server\ResponseTypes\ResponseTypeInterface;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
use League\Event\EmitterAwareInterface;
|
use League\Event\EmitterAwareInterface;
|
||||||
@ -41,11 +42,11 @@ interface GrantTypeInterface extends EmitterAwareInterface
|
|||||||
/**
|
/**
|
||||||
* Respond to an incoming request.
|
* Respond to an incoming request.
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param \League\OAuth2\Server\ResponseTypes\ResponseTypeInterface $responseType
|
* @param ResponseTypeInterface $responseType
|
||||||
* @param \DateInterval $accessTokenTTL
|
* @param \DateInterval $accessTokenTTL
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\ResponseTypes\ResponseTypeInterface
|
* @return ResponseTypeInterface
|
||||||
*/
|
*/
|
||||||
public function respondToAccessTokenRequest(
|
public function respondToAccessTokenRequest(
|
||||||
ServerRequestInterface $request,
|
ServerRequestInterface $request,
|
||||||
@ -56,7 +57,7 @@ interface GrantTypeInterface extends EmitterAwareInterface
|
|||||||
/**
|
/**
|
||||||
* The grant type should return true if it is able to response to an authorization request
|
* The grant type should return true if it is able to response to an authorization request
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@ -69,7 +70,7 @@ interface GrantTypeInterface extends EmitterAwareInterface
|
|||||||
* If the validation is successful an AuthorizationRequest object will be returned. This object can be safely
|
* If the validation is successful an AuthorizationRequest object will be returned. This object can be safely
|
||||||
* serialized in a user's session, and can be used during user authentication and authorization.
|
* serialized in a user's session, and can be used during user authentication and authorization.
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
*
|
*
|
||||||
* @return AuthorizationRequest
|
* @return AuthorizationRequest
|
||||||
*/
|
*/
|
||||||
@ -80,9 +81,9 @@ interface GrantTypeInterface extends EmitterAwareInterface
|
|||||||
* The AuthorizationRequest object's $userId property must be set to the authenticated user and the
|
* The AuthorizationRequest object's $userId property must be set to the authenticated user and the
|
||||||
* $authorizationApproved property must reflect their desire to authorize or deny the client.
|
* $authorizationApproved property must reflect their desire to authorize or deny the client.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\RequestTypes\AuthorizationRequest $authorizationRequest
|
* @param AuthorizationRequest $authorizationRequest
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\ResponseTypes\ResponseTypeInterface
|
* @return ResponseTypeInterface
|
||||||
*/
|
*/
|
||||||
public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest);
|
public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest);
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ interface GrantTypeInterface extends EmitterAwareInterface
|
|||||||
*
|
*
|
||||||
* For example most grant types will check that the $_POST['grant_type'] property matches it's identifier property.
|
* For example most grant types will check that the $_POST['grant_type'] property matches it's identifier property.
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@ -100,35 +101,35 @@ interface GrantTypeInterface extends EmitterAwareInterface
|
|||||||
/**
|
/**
|
||||||
* Set the client repository.
|
* Set the client repository.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Repositories\ClientRepositoryInterface $clientRepository
|
* @param ClientRepositoryInterface $clientRepository
|
||||||
*/
|
*/
|
||||||
public function setClientRepository(ClientRepositoryInterface $clientRepository);
|
public function setClientRepository(ClientRepositoryInterface $clientRepository);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the access token repository.
|
* Set the access token repository.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface $accessTokenRepository
|
* @param AccessTokenRepositoryInterface $accessTokenRepository
|
||||||
*/
|
*/
|
||||||
public function setAccessTokenRepository(AccessTokenRepositoryInterface $accessTokenRepository);
|
public function setAccessTokenRepository(AccessTokenRepositoryInterface $accessTokenRepository);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the scope repository.
|
* Set the scope repository.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Repositories\ScopeRepositoryInterface $scopeRepository
|
* @param ScopeRepositoryInterface $scopeRepository
|
||||||
*/
|
*/
|
||||||
public function setScopeRepository(ScopeRepositoryInterface $scopeRepository);
|
public function setScopeRepository(ScopeRepositoryInterface $scopeRepository);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the path to the private key.
|
* Set the path to the private key.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\CryptKey $privateKey
|
* @param CryptKey $privateKey
|
||||||
*/
|
*/
|
||||||
public function setPrivateKey(CryptKey $privateKey);
|
public function setPrivateKey(CryptKey $privateKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the path to the public key.
|
* Set the path to the public key.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\CryptKey $publicKey
|
* @param CryptKey $publicKey
|
||||||
*/
|
*/
|
||||||
public function setPublicKey(CryptKey $publicKey);
|
public function setPublicKey(CryptKey $publicKey);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class ImplicitGrant extends AbstractAuthorizeGrant
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface $refreshTokenRepository
|
* @param RefreshTokenRepositoryInterface $refreshTokenRepository
|
||||||
*
|
*
|
||||||
* @throw \LogicException
|
* @throw \LogicException
|
||||||
*/
|
*/
|
||||||
@ -75,11 +75,11 @@ class ImplicitGrant extends AbstractAuthorizeGrant
|
|||||||
/**
|
/**
|
||||||
* Respond to an incoming request.
|
* Respond to an incoming request.
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param \League\OAuth2\Server\ResponseTypes\ResponseTypeInterface $responseType
|
* @param ResponseTypeInterface $responseType
|
||||||
* @param \DateInterval $accessTokenTTL
|
* @param \DateInterval $accessTokenTTL
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\ResponseTypes\ResponseTypeInterface
|
* @return ResponseTypeInterface
|
||||||
*/
|
*/
|
||||||
public function respondToAccessTokenRequest(
|
public function respondToAccessTokenRequest(
|
||||||
ServerRequestInterface $request,
|
ServerRequestInterface $request,
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
||||||
@ -25,8 +26,8 @@ use Psr\Http\Message\ServerRequestInterface;
|
|||||||
class PasswordGrant extends AbstractGrant
|
class PasswordGrant extends AbstractGrant
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param \League\OAuth2\Server\Repositories\UserRepositoryInterface $userRepository
|
* @param UserRepositoryInterface $userRepository
|
||||||
* @param \League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface $refreshTokenRepository
|
* @param RefreshTokenRepositoryInterface $refreshTokenRepository
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
UserRepositoryInterface $userRepository,
|
UserRepositoryInterface $userRepository,
|
||||||
@ -66,12 +67,12 @@ class PasswordGrant extends AbstractGrant
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param \League\OAuth2\Server\Entities\ClientEntityInterface $client
|
* @param ClientEntityInterface $client
|
||||||
*
|
*
|
||||||
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
* @throws OAuthServerException
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\Entities\UserEntityInterface
|
* @return UserEntityInterface
|
||||||
*/
|
*/
|
||||||
protected function validateUser(ServerRequestInterface $request, ClientEntityInterface $client)
|
protected function validateUser(ServerRequestInterface $request, ClientEntityInterface $client)
|
||||||
{
|
{
|
||||||
@ -91,7 +92,7 @@ class PasswordGrant extends AbstractGrant
|
|||||||
$this->getIdentifier(),
|
$this->getIdentifier(),
|
||||||
$client
|
$client
|
||||||
);
|
);
|
||||||
if (!$user instanceof UserEntityInterface) {
|
if ($user instanceof UserEntityInterface === false) {
|
||||||
$this->getEmitter()->emit(new RequestEvent(RequestEvent::USER_AUTHENTICATION_FAILED, $request));
|
$this->getEmitter()->emit(new RequestEvent(RequestEvent::USER_AUTHENTICATION_FAILED, $request));
|
||||||
|
|
||||||
throw OAuthServerException::invalidCredentials();
|
throw OAuthServerException::invalidCredentials();
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
use League\OAuth2\Server\Entities\ScopeEntityInterface;
|
use League\OAuth2\Server\Entities\ScopeEntityInterface;
|
||||||
@ -23,7 +24,7 @@ use Psr\Http\Message\ServerRequestInterface;
|
|||||||
class RefreshTokenGrant extends AbstractGrant
|
class RefreshTokenGrant extends AbstractGrant
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param \League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface $refreshTokenRepository
|
* @param RefreshTokenRepositoryInterface $refreshTokenRepository
|
||||||
*/
|
*/
|
||||||
public function __construct(RefreshTokenRepositoryInterface $refreshTokenRepository)
|
public function __construct(RefreshTokenRepositoryInterface $refreshTokenRepository)
|
||||||
{
|
{
|
||||||
@ -50,7 +51,7 @@ class RefreshTokenGrant extends AbstractGrant
|
|||||||
$scopes = array_map(function ($scopeId) use ($client) {
|
$scopes = array_map(function ($scopeId) use ($client) {
|
||||||
$scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeId);
|
$scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeId);
|
||||||
|
|
||||||
if (!$scope instanceof ScopeEntityInterface) {
|
if ($scope instanceof ScopeEntityInterface === false) {
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
throw OAuthServerException::invalidScope($scopeId);
|
throw OAuthServerException::invalidScope($scopeId);
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
@ -84,10 +85,10 @@ class RefreshTokenGrant extends AbstractGrant
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param string $clientId
|
* @param string $clientId
|
||||||
*
|
*
|
||||||
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
* @throws OAuthServerException
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@ -17,14 +17,12 @@ use Psr\Http\Message\ServerRequestInterface;
|
|||||||
class AuthorizationServerMiddleware
|
class AuthorizationServerMiddleware
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\AuthorizationServer
|
* @var AuthorizationServer
|
||||||
*/
|
*/
|
||||||
private $server;
|
private $server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AuthorizationServerMiddleware constructor.
|
* @param AuthorizationServer $server
|
||||||
*
|
|
||||||
* @param \League\OAuth2\Server\AuthorizationServer $server
|
|
||||||
*/
|
*/
|
||||||
public function __construct(AuthorizationServer $server)
|
public function __construct(AuthorizationServer $server)
|
||||||
{
|
{
|
||||||
@ -32,11 +30,11 @@ class AuthorizationServerMiddleware
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param \Psr\Http\Message\ResponseInterface $response
|
* @param ResponseInterface $response
|
||||||
* @param callable $next
|
* @param callable $next
|
||||||
*
|
*
|
||||||
* @return \Psr\Http\Message\ResponseInterface
|
* @return ResponseInterface
|
||||||
*/
|
*/
|
||||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
|
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
|
||||||
{
|
{
|
||||||
|
@ -17,14 +17,12 @@ use Psr\Http\Message\ServerRequestInterface;
|
|||||||
class ResourceServerMiddleware
|
class ResourceServerMiddleware
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\ResourceServer
|
* @var ResourceServer
|
||||||
*/
|
*/
|
||||||
private $server;
|
private $server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResourceServerMiddleware constructor.
|
* @param ResourceServer $server
|
||||||
*
|
|
||||||
* @param \League\OAuth2\Server\ResourceServer $server
|
|
||||||
*/
|
*/
|
||||||
public function __construct(ResourceServer $server)
|
public function __construct(ResourceServer $server)
|
||||||
{
|
{
|
||||||
@ -32,8 +30,8 @@ class ResourceServerMiddleware
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
* @param \Psr\Http\Message\ResponseInterface $response
|
* @param ResponseInterface $response
|
||||||
* @param callable $next
|
* @param callable $next
|
||||||
*
|
*
|
||||||
* @return \Psr\Http\Message\ResponseInterface
|
* @return \Psr\Http\Message\ResponseInterface
|
||||||
|
@ -11,6 +11,7 @@ namespace League\OAuth2\Server\Repositories;
|
|||||||
|
|
||||||
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
||||||
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
||||||
|
use League\OAuth2\Server\Entities\ScopeEntityInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access token interface.
|
* Access token interface.
|
||||||
@ -20,8 +21,8 @@ interface AccessTokenRepositoryInterface extends RepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* Create a new access token
|
* Create a new access token
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Entities\ClientEntityInterface $clientEntity
|
* @param ClientEntityInterface $clientEntity
|
||||||
* @param \League\OAuth2\Server\Entities\ScopeEntityInterface[] $scopes
|
* @param ScopeEntityInterface[] $scopes
|
||||||
* @param mixed $userIdentifier
|
* @param mixed $userIdentifier
|
||||||
*
|
*
|
||||||
* @return AccessTokenEntityInterface
|
* @return AccessTokenEntityInterface
|
||||||
@ -31,7 +32,7 @@ interface AccessTokenRepositoryInterface extends RepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* Persists a new access token to permanent storage.
|
* Persists a new access token to permanent storage.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Entities\AccessTokenEntityInterface $accessTokenEntity
|
* @param AccessTokenEntityInterface $accessTokenEntity
|
||||||
*/
|
*/
|
||||||
public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity);
|
public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity);
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server\Repositories;
|
namespace League\OAuth2\Server\Repositories;
|
||||||
|
|
||||||
use League\OAuth2\Server\Entities\AuthCodeEntityInterface;
|
use League\OAuth2\Server\Entities\AuthCodeEntityInterface;
|
||||||
@ -18,14 +19,14 @@ interface AuthCodeRepositoryInterface extends RepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* Creates a new AuthCode
|
* Creates a new AuthCode
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\Entities\AuthCodeEntityInterface
|
* @return AuthCodeEntityInterface
|
||||||
*/
|
*/
|
||||||
public function getNewAuthCode();
|
public function getNewAuthCode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persists a new auth code to permanent storage.
|
* Persists a new auth code to permanent storage.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Entities\AuthCodeEntityInterface $authCodeEntity
|
* @param AuthCodeEntityInterface $authCodeEntity
|
||||||
*/
|
*/
|
||||||
public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity);
|
public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity);
|
||||||
|
|
||||||
|
@ -6,8 +6,11 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server\Repositories;
|
namespace League\OAuth2\Server\Repositories;
|
||||||
|
|
||||||
|
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client storage interface.
|
* Client storage interface.
|
||||||
*/
|
*/
|
||||||
@ -19,10 +22,10 @@ interface ClientRepositoryInterface extends RepositoryInterface
|
|||||||
* @param string $clientIdentifier The client's identifier
|
* @param string $clientIdentifier The client's identifier
|
||||||
* @param string $grantType The grant type used
|
* @param string $grantType The grant type used
|
||||||
* @param null|string $clientSecret The client's secret (if sent)
|
* @param null|string $clientSecret The client's secret (if sent)
|
||||||
* @param bool $mustValidateSecret If true the client must attempt to validate the secret unless the client
|
* @param bool $mustValidateSecret If true the client must attempt to validate the secret if the client
|
||||||
* is confidential
|
* is confidential
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\Entities\ClientEntityInterface
|
* @return ClientEntityInterface
|
||||||
*/
|
*/
|
||||||
public function getClientEntity($clientIdentifier, $grantType, $clientSecret = null, $mustValidateSecret = true);
|
public function getClientEntity($clientIdentifier, $grantType, $clientSecret = null, $mustValidateSecret = true);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server\Repositories;
|
namespace League\OAuth2\Server\Repositories;
|
||||||
|
|
||||||
use League\OAuth2\Server\Entities\RefreshTokenEntityInterface;
|
use League\OAuth2\Server\Entities\RefreshTokenEntityInterface;
|
||||||
@ -25,7 +26,7 @@ interface RefreshTokenRepositoryInterface extends RepositoryInterface
|
|||||||
/**
|
/**
|
||||||
* Create a new refresh token_name.
|
* Create a new refresh token_name.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Entities\RefreshTokenEntityInterface $refreshTokenEntity
|
* @param RefreshTokenEntityInterface $refreshTokenEntity
|
||||||
*/
|
*/
|
||||||
public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshTokenEntity);
|
public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshTokenEntity);
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server\Repositories;
|
namespace League\OAuth2\Server\Repositories;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,7 @@ interface ScopeRepositoryInterface extends RepositoryInterface
|
|||||||
*
|
*
|
||||||
* @param string $identifier The scope identifier
|
* @param string $identifier The scope identifier
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\Entities\ScopeEntityInterface
|
* @return ScopeEntityInterface
|
||||||
*/
|
*/
|
||||||
public function getScopeEntityByIdentifier($identifier);
|
public function getScopeEntityByIdentifier($identifier);
|
||||||
|
|
||||||
@ -32,10 +32,10 @@ interface ScopeRepositoryInterface extends RepositoryInterface
|
|||||||
*
|
*
|
||||||
* @param ScopeEntityInterface[] $scopes
|
* @param ScopeEntityInterface[] $scopes
|
||||||
* @param string $grantType
|
* @param string $grantType
|
||||||
* @param \League\OAuth2\Server\Entities\ClientEntityInterface $clientEntity
|
* @param ClientEntityInterface $clientEntity
|
||||||
* @param null|string $userIdentifier
|
* @param null|string $userIdentifier
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\Entities\ScopeEntityInterface[]
|
* @return ScopeEntityInterface[]
|
||||||
*/
|
*/
|
||||||
public function finalizeScopes(
|
public function finalizeScopes(
|
||||||
array $scopes,
|
array $scopes,
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
namespace League\OAuth2\Server\Repositories;
|
namespace League\OAuth2\Server\Repositories;
|
||||||
|
|
||||||
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
use League\OAuth2\Server\Entities\ClientEntityInterface;
|
||||||
|
use League\OAuth2\Server\Entities\UserEntityInterface;
|
||||||
|
|
||||||
interface UserRepositoryInterface extends RepositoryInterface
|
interface UserRepositoryInterface extends RepositoryInterface
|
||||||
{
|
{
|
||||||
@ -19,9 +20,9 @@ interface UserRepositoryInterface extends RepositoryInterface
|
|||||||
* @param string $username
|
* @param string $username
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @param string $grantType The grant type used
|
* @param string $grantType The grant type used
|
||||||
* @param \League\OAuth2\Server\Entities\ClientEntityInterface $clientEntity
|
* @param ClientEntityInterface $clientEntity
|
||||||
*
|
*
|
||||||
* @return \League\OAuth2\Server\Entities\UserEntityInterface
|
* @return UserEntityInterface
|
||||||
*/
|
*/
|
||||||
public function getUserEntityByUserCredentials(
|
public function getUserEntityByUserCredentials(
|
||||||
$username,
|
$username,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server;
|
namespace League\OAuth2\Server;
|
||||||
|
|
||||||
use League\Event\Event;
|
use League\Event\Event;
|
||||||
@ -18,7 +19,7 @@ class RequestEvent extends Event
|
|||||||
const REFRESH_TOKEN_CLIENT_FAILED = 'refresh_token.client.failed';
|
const REFRESH_TOKEN_CLIENT_FAILED = 'refresh_token.client.failed';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Psr\Http\Message\ServerRequestInterface
|
* @var ServerRequestInterface
|
||||||
*/
|
*/
|
||||||
private $request;
|
private $request;
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ class RequestEvent extends Event
|
|||||||
* RequestEvent constructor.
|
* RequestEvent constructor.
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
*/
|
*/
|
||||||
public function __construct($name, ServerRequestInterface $request)
|
public function __construct($name, ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
|
@ -125,7 +125,7 @@ class AuthorizationRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \League\OAuth2\Server\Entities\ScopeEntityInterface[]
|
* @return ScopeEntityInterface[]
|
||||||
*/
|
*/
|
||||||
public function getScopes()
|
public function getScopes()
|
||||||
{
|
{
|
||||||
@ -133,9 +133,9 @@ class AuthorizationRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \League\OAuth2\Server\Entities\ScopeEntityInterface[] $scopes
|
* @param ScopeEntityInterface[] $scopes
|
||||||
*/
|
*/
|
||||||
public function setScopes($scopes)
|
public function setScopes(array $scopes)
|
||||||
{
|
{
|
||||||
$this->scopes = $scopes;
|
$this->scopes = $scopes;
|
||||||
}
|
}
|
||||||
|
@ -6,34 +6,38 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server;
|
namespace League\OAuth2\Server;
|
||||||
|
|
||||||
use League\OAuth2\Server\AuthorizationValidators\AuthorizationValidatorInterface;
|
use League\OAuth2\Server\AuthorizationValidators\AuthorizationValidatorInterface;
|
||||||
use League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator;
|
use League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator;
|
||||||
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||||
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
class ResourceServer
|
class ResourceServer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface
|
* @var AccessTokenRepositoryInterface
|
||||||
*/
|
*/
|
||||||
private $accessTokenRepository;
|
private $accessTokenRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\CryptKey|string
|
* @var CryptKey
|
||||||
*/
|
*/
|
||||||
private $publicKey;
|
private $publicKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\AuthorizationValidators\AuthorizationValidatorInterface|null
|
* @var null|AuthorizationValidatorInterface
|
||||||
*/
|
*/
|
||||||
private $authorizationValidator;
|
private $authorizationValidator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New server instance.
|
* New server instance.
|
||||||
*
|
*
|
||||||
* @param \League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface $accessTokenRepository
|
* @param AccessTokenRepositoryInterface $accessTokenRepository
|
||||||
* @param \League\OAuth2\Server\CryptKey|string $publicKey
|
* @param CryptKey|string $publicKey
|
||||||
* @param null|\League\OAuth2\Server\AuthorizationValidators\AuthorizationValidatorInterface $authorizationValidator
|
* @param null|AuthorizationValidatorInterface $authorizationValidator
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AccessTokenRepositoryInterface $accessTokenRepository,
|
AccessTokenRepositoryInterface $accessTokenRepository,
|
||||||
@ -42,7 +46,7 @@ class ResourceServer
|
|||||||
) {
|
) {
|
||||||
$this->accessTokenRepository = $accessTokenRepository;
|
$this->accessTokenRepository = $accessTokenRepository;
|
||||||
|
|
||||||
if (!$publicKey instanceof CryptKey) {
|
if ($publicKey instanceof CryptKey === false) {
|
||||||
$publicKey = new CryptKey($publicKey);
|
$publicKey = new CryptKey($publicKey);
|
||||||
}
|
}
|
||||||
$this->publicKey = $publicKey;
|
$this->publicKey = $publicKey;
|
||||||
@ -51,11 +55,11 @@ class ResourceServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \League\OAuth2\Server\AuthorizationValidators\AuthorizationValidatorInterface
|
* @return AuthorizationValidatorInterface
|
||||||
*/
|
*/
|
||||||
protected function getAuthorizationValidator()
|
protected function getAuthorizationValidator()
|
||||||
{
|
{
|
||||||
if (!$this->authorizationValidator instanceof AuthorizationValidatorInterface) {
|
if ($this->authorizationValidator instanceof AuthorizationValidatorInterface === false) {
|
||||||
$this->authorizationValidator = new BearerTokenValidator($this->accessTokenRepository);
|
$this->authorizationValidator = new BearerTokenValidator($this->accessTokenRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,11 +71,11 @@ class ResourceServer
|
|||||||
/**
|
/**
|
||||||
* Determine the access token validity.
|
* Determine the access token validity.
|
||||||
*
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
*
|
*
|
||||||
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
* @throws OAuthServerException
|
||||||
*
|
*
|
||||||
* @return \Psr\Http\Message\ServerRequestInterface
|
* @return ServerRequestInterface
|
||||||
*/
|
*/
|
||||||
public function validateAuthenticatedRequest(ServerRequestInterface $request)
|
public function validateAuthenticatedRequest(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server\ResponseTypes;
|
namespace League\OAuth2\Server\ResponseTypes;
|
||||||
|
|
||||||
use League\OAuth2\Server\CryptTrait;
|
use League\OAuth2\Server\CryptTrait;
|
||||||
@ -19,12 +20,12 @@ abstract class AbstractResponseType implements ResponseTypeInterface
|
|||||||
use CryptTrait;
|
use CryptTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\Entities\AccessTokenEntityInterface
|
* @var AccessTokenEntityInterface
|
||||||
*/
|
*/
|
||||||
protected $accessToken;
|
protected $accessToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \League\OAuth2\Server\Entities\RefreshTokenEntityInterface
|
* @var RefreshTokenEntityInterface
|
||||||
*/
|
*/
|
||||||
protected $refreshToken;
|
protected $refreshToken;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* OAuth 2.0 Bearer Token Type.
|
* OAuth 2.0 Bearer Token Response.
|
||||||
*
|
*
|
||||||
* @author Alex Bilbie <hello@alexbilbie.com>
|
* @author Alex Bilbie <hello@alexbilbie.com>
|
||||||
* @copyright Copyright (c) Alex Bilbie
|
* @copyright Copyright (c) Alex Bilbie
|
||||||
@ -8,6 +8,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server\ResponseTypes;
|
namespace League\OAuth2\Server\ResponseTypes;
|
||||||
|
|
||||||
use League\OAuth2\Server\Entities\RefreshTokenEntityInterface;
|
use League\OAuth2\Server\Entities\RefreshTokenEntityInterface;
|
||||||
|
@ -1,4 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* OAuth 2.0 Redirect Response.
|
||||||
|
*
|
||||||
|
* @author Alex Bilbie <hello@alexbilbie.com>
|
||||||
|
* @copyright Copyright (c) Alex Bilbie
|
||||||
|
* @license http://mit-license.org/
|
||||||
|
*
|
||||||
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server\ResponseTypes;
|
namespace League\OAuth2\Server\ResponseTypes;
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
*
|
*
|
||||||
* @link https://github.com/thephpleague/oauth2-server
|
* @link https://github.com/thephpleague/oauth2-server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace League\OAuth2\Server\ResponseTypes;
|
namespace League\OAuth2\Server\ResponseTypes;
|
||||||
|
|
||||||
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
|
||||||
@ -17,12 +18,12 @@ use Psr\Http\Message\ResponseInterface;
|
|||||||
interface ResponseTypeInterface
|
interface ResponseTypeInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param \League\OAuth2\Server\Entities\AccessTokenEntityInterface $accessToken
|
* @param AccessTokenEntityInterface $accessToken
|
||||||
*/
|
*/
|
||||||
public function setAccessToken(AccessTokenEntityInterface $accessToken);
|
public function setAccessToken(AccessTokenEntityInterface $accessToken);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \League\OAuth2\Server\Entities\RefreshTokenEntityInterface $refreshToken
|
* @param RefreshTokenEntityInterface $refreshToken
|
||||||
*/
|
*/
|
||||||
public function setRefreshToken(RefreshTokenEntityInterface $refreshToken);
|
public function setRefreshToken(RefreshTokenEntityInterface $refreshToken);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user