mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-01 16:33:07 +05:30
Add optional default scope parameter.
Signed-off-by: Michael Gooden <me@michaelgooden.net>
This commit is contained in:
parent
26781d2c38
commit
5bd62fe942
@ -63,6 +63,12 @@ class AuthServer
|
||||
*/
|
||||
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()
|
||||
* @var boolean
|
||||
@ -186,6 +192,15 @@ class AuthServer
|
||||
$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()
|
||||
* @param boolean $require
|
||||
@ -323,6 +338,8 @@ class AuthServer
|
||||
|
||||
if ($this->requireScopeParam === true && count($scopes) === 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();
|
||||
|
Loading…
Reference in New Issue
Block a user