mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-16 18:19:47 +05:30
Fix #164
This commit is contained in:
parent
e32f153acf
commit
6a0596f40b
@ -74,22 +74,22 @@ class AuthCodeGrant extends AbstractGrant
|
||||
public function checkAuthoriseParams()
|
||||
{
|
||||
// Get required params
|
||||
$clientId = $this->server->getRequest()->request->get('client_id', null);
|
||||
$clientId = $this->server->getRequest()->query->get('client_id', null);
|
||||
if (is_null($clientId)) {
|
||||
throw new Exception\InvalidRequestException('client_id');
|
||||
}
|
||||
|
||||
$redirectUri = $this->server->getRequest()->request->get('redirect_uri', null);
|
||||
$redirectUri = $this->server->getRequest()->query->get('redirect_uri', null);
|
||||
if (is_null($redirectUri)) {
|
||||
throw new Exception\InvalidRequestException('redirect_uri');
|
||||
}
|
||||
|
||||
$state = $this->server->getRequest()->request->get('state', null);
|
||||
$state = $this->server->getRequest()->query->get('state', null);
|
||||
if ($this->server->stateParamRequired() === true && is_null($state)) {
|
||||
throw new Exception\InvalidRequestException('state');
|
||||
}
|
||||
|
||||
$responseType = $this->server->getRequest()->request->get('response_type', null);
|
||||
$responseType = $this->server->getRequest()->query->get('response_type', null);
|
||||
if (is_null($responseType)) {
|
||||
throw new Exception\InvalidRequestException('response_type');
|
||||
}
|
||||
@ -112,7 +112,7 @@ class AuthCodeGrant extends AbstractGrant
|
||||
}
|
||||
|
||||
// Validate any scopes that are in the request
|
||||
$scopeParam = $this->server->getRequest()->request->get('scope', '');
|
||||
$scopeParam = $this->server->getRequest()->query->get('scope', '');
|
||||
$scopes = $this->validateScopes($scopeParam);
|
||||
|
||||
return [
|
||||
|
@ -29,7 +29,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
|
||||
|
||||
$_POST = [];
|
||||
$_GET = [];
|
||||
$server = new AuthorizationServer;
|
||||
|
||||
$grant = new AuthCodeGrant;
|
||||
@ -44,7 +44,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
||||
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
|
||||
|
||||
$server = new AuthorizationServer;
|
||||
$_POST = [
|
||||
$_GET = [
|
||||
'client_id' => 'testapp'
|
||||
];
|
||||
|
||||
@ -58,7 +58,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
|
||||
|
||||
$_POST = [
|
||||
$_GET = [
|
||||
'client_id' => 'testapp',
|
||||
'redirect_uri' => 'http://foo/bar'
|
||||
];
|
||||
@ -75,7 +75,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
|
||||
|
||||
$_POST = [
|
||||
$_GET = [
|
||||
'client_id' => 'testapp',
|
||||
'redirect_uri' => 'http://foo/bar'
|
||||
];
|
||||
@ -91,7 +91,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException('League\OAuth2\Server\Exception\UnsupportedResponseTypeException');
|
||||
|
||||
$_POST = [
|
||||
$_GET = [
|
||||
'client_id' => 'testapp',
|
||||
'redirect_uri' => 'http://foo/bar',
|
||||
'response_type' => 'foobar'
|
||||
@ -108,7 +108,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidClientException');
|
||||
|
||||
$_POST = [
|
||||
$_GET = [
|
||||
'client_id' => 'testapp',
|
||||
'redirect_uri' => 'http://foo/bar',
|
||||
'response_type' => 'code'
|
||||
@ -131,7 +131,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidScopeException');
|
||||
|
||||
$_POST = [
|
||||
$_GET = [
|
||||
'response_type' => 'code',
|
||||
'client_id' => 'testapp',
|
||||
'redirect_uri' => 'http://foo/bar',
|
||||
@ -172,7 +172,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testCheckAuthoriseParams()
|
||||
{
|
||||
$_POST = [
|
||||
$_GET = [
|
||||
'response_type' => 'code',
|
||||
'client_id' => 'testapp',
|
||||
'redirect_uri' => 'http://foo/bar',
|
||||
@ -220,7 +220,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase
|
||||
$result = $grant->checkAuthoriseParams();
|
||||
|
||||
$this->assertTrue($result['client'] instanceof ClientEntity);
|
||||
$this->assertTrue($result['redirect_uri'] === $_POST['redirect_uri']);
|
||||
$this->assertTrue($result['redirect_uri'] === $_GET['redirect_uri']);
|
||||
$this->assertTrue($result['state'] === null);
|
||||
$this->assertTrue($result['response_type'] === 'code');
|
||||
$this->assertTrue($result['scopes']['foo'] instanceof ScopeEntity);
|
||||
|
Loading…
Reference in New Issue
Block a user