mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-15 17:56:14 +05:30
Updated server methods
This commit is contained in:
parent
4bc835c007
commit
d4fb00628e
@ -12,6 +12,7 @@ use League\OAuth2\Server\Grant\GrantTypeInterface;
|
|||||||
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
||||||
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
|
||||||
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
|
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
|
||||||
|
use League\OAuth2\Server\RequestTypes\AuthorizationRequest;
|
||||||
use League\OAuth2\Server\ResponseTypes\BearerTokenResponse;
|
use League\OAuth2\Server\ResponseTypes\BearerTokenResponse;
|
||||||
use League\OAuth2\Server\ResponseTypes\ResponseTypeInterface;
|
use League\OAuth2\Server\ResponseTypes\ResponseTypeInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
@ -125,27 +126,44 @@ class Server implements EmitterAwareInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Validate an authorization request
|
||||||
|
*
|
||||||
* @param \Psr\Http\Message\ServerRequestInterface $request
|
* @param \Psr\Http\Message\ServerRequestInterface $request
|
||||||
*
|
*
|
||||||
|
* @return \League\OAuth2\Server\RequestTypes\AuthorizationRequest|null
|
||||||
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
* @throws \League\OAuth2\Server\Exception\OAuthServerException
|
||||||
*/
|
*/
|
||||||
public function respondToAuthorizationRequest(ServerRequestInterface $request)
|
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
$authRequest = null;
|
$authRequest = null;
|
||||||
while ($authRequest === null && $grantType = array_shift($this->enabledGrantTypes)) {
|
$enabledGrantTypes = $this->enabledGrantTypes;
|
||||||
|
while ($authRequest === null && $grantType = array_shift($enabledGrantTypes)) {
|
||||||
/** @var \League\OAuth2\Server\Grant\GrantTypeInterface $grantType */
|
/** @var \League\OAuth2\Server\Grant\GrantTypeInterface $grantType */
|
||||||
if ($grantType->canRespondToAccessTokenRequest($request)) {
|
if ($grantType->canRespondToAuthorizationRequest($request)) {
|
||||||
$authRequest = $grantType->respondToRequest(
|
$authRequest = $grantType->validateAuthorizationRequest($request);
|
||||||
$request,
|
|
||||||
$this->getResponseType(),
|
return $authRequest;
|
||||||
$this->grantTypeAccessTokenTTL[$grantType->getIdentifier()]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw OAuthServerException::unsupportedGrantType();
|
throw OAuthServerException::unsupportedGrantType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Complete an authorization request
|
||||||
|
*
|
||||||
|
* @param \League\OAuth2\Server\RequestTypes\AuthorizationRequest $authRequest
|
||||||
|
* @param \Psr\Http\Message\ResponseInterface $response
|
||||||
|
*
|
||||||
|
* @return \League\OAuth2\Server\ResponseTypes\ResponseTypeInterface
|
||||||
|
*/
|
||||||
|
public function completeAuthorizationRequest(AuthorizationRequest $authRequest, ResponseInterface $response)
|
||||||
|
{
|
||||||
|
return $this->enabledGrantTypes[$authRequest->getGrantTypeId()]
|
||||||
|
->completeAuthorizationRequest($authRequest)
|
||||||
|
->generateHttpResponse($response);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an access token response.
|
* Return an access token response.
|
||||||
*
|
*
|
||||||
@ -162,7 +180,7 @@ class Server implements EmitterAwareInterface
|
|||||||
while ($tokenResponse === null && $grantType = array_shift($this->enabledGrantTypes)) {
|
while ($tokenResponse === null && $grantType = array_shift($this->enabledGrantTypes)) {
|
||||||
/** @var \League\OAuth2\Server\Grant\GrantTypeInterface $grantType */
|
/** @var \League\OAuth2\Server\Grant\GrantTypeInterface $grantType */
|
||||||
if ($grantType->canRespondToAccessTokenRequest($request)) {
|
if ($grantType->canRespondToAccessTokenRequest($request)) {
|
||||||
$tokenResponse = $grantType->respondToRequest(
|
$tokenResponse = $grantType->respondToAccessTokenRequest(
|
||||||
$request,
|
$request,
|
||||||
$this->getResponseType(),
|
$this->getResponseType(),
|
||||||
$this->grantTypeAccessTokenTTL[$grantType->getIdentifier()]
|
$this->grantTypeAccessTokenTTL[$grantType->getIdentifier()]
|
||||||
|
Loading…
Reference in New Issue
Block a user