Set the scope parameter to not be required by default. Fixes #43

This commit is contained in:
Alex Bilbie 2013-05-09 10:02:41 -07:00
parent c3b41a5e8a
commit ddefb2ee16
3 changed files with 5 additions and 4 deletions

View File

@ -59,10 +59,10 @@ class Authorization
* Require the "scope" parameter to be in checkAuthoriseParams() * Require the "scope" parameter to be in checkAuthoriseParams()
* @var boolean * @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 * @var string
*/ */
protected $defaultScope = null; protected $defaultScope = null;
@ -271,7 +271,7 @@ class Authorization
* @param boolean $require * @param boolean $require
* @return void * @return void
*/ */
public function requireScopeParam($require = true) public function requireScopeParam($require = false)
{ {
$this->requireScopeParam = $require; $this->requireScopeParam = $require;
} }

View File

@ -152,7 +152,7 @@ class AuthCode implements GrantTypeInterface {
if ($scopes[$i] === '') unset($scopes[$i]); // Remove any junk scopes 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); throw new Exception\ClientException(sprintf($this->authServer->getExceptionMessage('invalid_request'), 'scope'), 0);
} elseif (count($scopes) === 0 && $this->authServer->getDefaultScope()) { } elseif (count($scopes) === 0 && $this->authServer->getDefaultScope()) {
$scopes = array($this->authServer->getDefaultScope()); $scopes = array($this->authServer->getDefaultScope());

View File

@ -156,6 +156,7 @@ class Auth_Code_Grant_Test extends PHPUnit_Framework_TestCase
$g = new League\OAuth2\Server\Grant\AuthCode($a); $g = new League\OAuth2\Server\Grant\AuthCode($a);
$a->addGrantType($g); $a->addGrantType($g);
$a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a)); $a->addGrantType(new League\OAuth2\Server\Grant\AuthCode($a));
$a->requireScopeParam(true);
$g->checkAuthoriseParams(array( $g->checkAuthoriseParams(array(
'client_id' => 1234, 'client_id' => 1234,