mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-23 13:39:48 +05:30
Merge branch 'V5-authorization-request-flow' of github.com:thephpleague/oauth2-server into V5-authorization-request-flow
This commit is contained in:
commit
0fb0100088
@ -81,6 +81,7 @@ $app->get('/authorize', function (ServerRequestInterface $request, ResponseInter
|
|||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
$body = new Stream('php://temp', 'r+');
|
$body = new Stream('php://temp', 'r+');
|
||||||
$body->write($exception->getMessage());
|
$body->write($exception->getMessage());
|
||||||
|
|
||||||
return $response->withStatus(500)->withBody($body);
|
return $response->withStatus(500)->withBody($body);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
namespace League\OAuth2\Server\Grant;
|
namespace League\OAuth2\Server\Grant;
|
||||||
|
|
||||||
use League\Plates\Engine;
|
|
||||||
|
|
||||||
abstract class AbstractAuthorizeGrant extends AbstractGrant
|
abstract class AbstractAuthorizeGrant extends AbstractGrant
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -406,7 +406,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function canRespondToAuthorizationRequest(ServerRequestInterface $request)
|
public function canRespondToAuthorizationRequest(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
@ -414,7 +414,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
@ -422,7 +422,7 @@ abstract class AbstractGrant implements GrantTypeInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest)
|
public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest)
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function canRespondToAuthorizationRequest(ServerRequestInterface $request)
|
public function canRespondToAuthorizationRequest(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
@ -144,7 +144,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
@ -203,7 +203,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest)
|
public function completeAuthorizationRequest(AuthorizationRequest $authorizationRequest)
|
||||||
{
|
{
|
||||||
@ -219,7 +219,6 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
|
|
||||||
// The user approved the client, redirect them back with an auth code
|
// The user approved the client, redirect them back with an auth code
|
||||||
if ($authorizationRequest->isAuthorizationApproved() === true) {
|
if ($authorizationRequest->isAuthorizationApproved() === true) {
|
||||||
|
|
||||||
$authCode = $this->issueAuthCode(
|
$authCode = $this->issueAuthCode(
|
||||||
$this->authCodeTTL,
|
$this->authCodeTTL,
|
||||||
$authorizationRequest->getClient(),
|
$authorizationRequest->getClient(),
|
||||||
|
@ -10,42 +10,49 @@ class AuthorizationRequest
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The grant type identifier
|
* The grant type identifier
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $grantTypeId;
|
protected $grantTypeId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client identifier
|
* The client identifier
|
||||||
|
*
|
||||||
* @var ClientEntityInterface
|
* @var ClientEntityInterface
|
||||||
*/
|
*/
|
||||||
protected $client;
|
protected $client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user identifier
|
* The user identifier
|
||||||
|
*
|
||||||
* @var UserEntityInterface
|
* @var UserEntityInterface
|
||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of scope identifiers
|
* An array of scope identifiers
|
||||||
|
*
|
||||||
* @var ScopeEntityInterface[]
|
* @var ScopeEntityInterface[]
|
||||||
*/
|
*/
|
||||||
protected $scopes = [];
|
protected $scopes = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has the user authorized the authorization request
|
* Has the user authorized the authorization request
|
||||||
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $authorizationApproved = false;
|
protected $authorizationApproved = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The redirect URI used in the request
|
* The redirect URI used in the request
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $redirectUri;
|
protected $redirectUri;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The state parameter on the authorization request
|
* The state parameter on the authorization request
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $state;
|
protected $state;
|
||||||
@ -115,7 +122,7 @@ class AuthorizationRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isAuthorizationApproved()
|
public function isAuthorizationApproved()
|
||||||
{
|
{
|
||||||
@ -123,7 +130,7 @@ class AuthorizationRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param boolean $authorizationApproved
|
* @param bool $authorizationApproved
|
||||||
*/
|
*/
|
||||||
public function setAuthorizationApproved($authorizationApproved)
|
public function setAuthorizationApproved($authorizationApproved)
|
||||||
{
|
{
|
||||||
@ -161,5 +168,4 @@ class AuthorizationRequest
|
|||||||
{
|
{
|
||||||
$this->state = $state;
|
$this->state = $state;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -130,8 +130,9 @@ class Server implements EmitterAwareInterface
|
|||||||
*
|
*
|
||||||
* @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
|
||||||
|
*
|
||||||
|
* @return \League\OAuth2\Server\RequestTypes\AuthorizationRequest|null
|
||||||
*/
|
*/
|
||||||
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
|
@ -3,16 +3,15 @@
|
|||||||
namespace LeagueTests\ResponseTypes;
|
namespace LeagueTests\ResponseTypes;
|
||||||
|
|
||||||
use League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator;
|
use League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator;
|
||||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
|
||||||
|
|
||||||
use League\OAuth2\Server\CryptKey;
|
use League\OAuth2\Server\CryptKey;
|
||||||
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||||
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
|
||||||
use League\OAuth2\Server\ResponseTypes\BearerTokenResponse;
|
use League\OAuth2\Server\ResponseTypes\BearerTokenResponse;
|
||||||
|
use LeagueTests\Stubs\AccessTokenEntity;
|
||||||
use LeagueTests\Stubs\ClientEntity;
|
use LeagueTests\Stubs\ClientEntity;
|
||||||
use LeagueTests\Stubs\RefreshTokenEntity;
|
use LeagueTests\Stubs\RefreshTokenEntity;
|
||||||
use LeagueTests\Stubs\ScopeEntity;
|
use LeagueTests\Stubs\ScopeEntity;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use LeagueTests\Stubs\AccessTokenEntity;
|
|
||||||
use Zend\Diactoros\Response;
|
use Zend\Diactoros\Response;
|
||||||
use Zend\Diactoros\ServerRequest;
|
use Zend\Diactoros\ServerRequest;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user