mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-16 02:08:56 +05:30
Set the scope parameter to not be required by default. Fixes #43
This commit is contained in:
parent
c3b41a5e8a
commit
ddefb2ee16
@ -59,10 +59,10 @@ class Authorization
|
||||
* Require the "scope" parameter to be in checkAuthoriseParams()
|
||||
* @var boolean
|
||||
*/
|
||||
protected $requireScopeParam = true;
|
||||
protected $requireScopeParam = false;
|
||||
|
||||
/**
|
||||
* Default scope to be used if none is provided and requireScopeParam is false
|
||||
* Default scope to be used if none is provided
|
||||
* @var string
|
||||
*/
|
||||
protected $defaultScope = null;
|
||||
@ -271,7 +271,7 @@ class Authorization
|
||||
* @param boolean $require
|
||||
* @return void
|
||||
*/
|
||||
public function requireScopeParam($require = true)
|
||||
public function requireScopeParam($require = false)
|
||||
{
|
||||
$this->requireScopeParam = $require;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ class AuthCode implements GrantTypeInterface {
|
||||
if ($scopes[$i] === '') unset($scopes[$i]); // Remove any junk scopes
|
||||
}
|
||||
|
||||
if ($this->authServer->scopeParamRequired() === true && count($scopes) === 0) {
|
||||
if ($this->authServer->scopeParamRequired() === true && $this->authServer->getDefaultScope() === null && count($scopes) === 0) {
|
||||
throw new Exception\ClientException(sprintf($this->authServer->getExceptionMessage('invalid_request'), 'scope'), 0);
|
||||
} elseif (count($scopes) === 0 && $this->authServer->getDefaultScope()) {
|
||||
$scopes = array($this->authServer->getDefaultScope());
|
||||
|
@ -156,6 +156,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
|
||||
$g = new League\OAuth2\Server\Grant\AuthCode($a);
|
||||
$a->addGrantType($g);
|
||||
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
|
||||
$a->requireScopeParam(true);
|
||||
|
||||
$g->checkAuthoriseParams(array(
|
||||
'client_id' => 1234,
|
||||
|
Loading…
Reference in New Issue
Block a user