Add optional default scope parameter.

Signed-off-by: Michael Gooden <me@michaelgooden.net>
This commit is contained in:
Michael Gooden 2013-03-04 17:46:02 +02:00 committed by Alex Bilbie
parent 26781d2c38
commit 5bd62fe942

View File

@ -63,6 +63,12 @@ class AuthServer
*/ */
protected $requireScopeParam = true; protected $requireScopeParam = true;
/**
* Default scope to be used if none is provided and requireScopeParam is false
* @var string
*/
protected $defaultScope = null;
/** /**
* Require the "state" parameter to be in checkAuthoriseParams() * Require the "state" parameter to be in checkAuthoriseParams()
* @var boolean * @var boolean
@ -186,6 +192,15 @@ class AuthServer
$this->requireScopeParam = $require; $this->requireScopeParam = $require;
} }
/**
* Default scope to be used if none is provided and requireScopeParam is false
* @var string
*/
public function defaultScope($default = null)
{
$this->defaultScope = $default;
}
/** /**
* Require the "state" paremter in checkAuthoriseParams() * Require the "state" paremter in checkAuthoriseParams()
* @param boolean $require * @param boolean $require
@ -323,6 +338,8 @@ class AuthServer
if ($this->requireScopeParam === true && count($scopes) === 0) { if ($this->requireScopeParam === true && count($scopes) === 0) {
throw new Exception\ClientException(sprintf(self::$exceptionMessages['invalid_request'], 'scope'), 0); throw new Exception\ClientException(sprintf(self::$exceptionMessages['invalid_request'], 'scope'), 0);
} elseif (count($scopes) === 0 && $this->defaultScope) {
$scopes = array($this->defaultScope);
} }
$authParams['scopes'] = array(); $authParams['scopes'] = array();