mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-05-31 14:12:07 +05:30
Allow for multiple default scopes. Fixes #42
This commit is contained in:
@@ -62,8 +62,8 @@ class Authorization
|
||||
protected $requireScopeParam = false;
|
||||
|
||||
/**
|
||||
* Default scope to be used if none is provided
|
||||
* @var string
|
||||
* Default scope(s) to be used if none is provided
|
||||
* @var string|array
|
||||
*/
|
||||
protected $defaultScope = null;
|
||||
|
||||
@@ -287,7 +287,7 @@ class Authorization
|
||||
|
||||
/**
|
||||
* Default scope to be used if none is provided and requireScopeParam is false
|
||||
* @var string
|
||||
* @var string|array
|
||||
*/
|
||||
public function setDefaultScope($default = null)
|
||||
{
|
||||
|
@@ -154,8 +154,12 @@ class AuthCode implements GrantTypeInterface {
|
||||
|
||||
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());
|
||||
} elseif (count($scopes) === 0 && $this->authServer->getDefaultScope() !== null) {
|
||||
if (is_array($this->authServer->getDefaultScope())) {
|
||||
$scopes = $this->authServer->getDefaultScope();
|
||||
} else {
|
||||
$scopes = array($this->authServer->getDefaultScope());
|
||||
}
|
||||
}
|
||||
|
||||
$authParams['scopes'] = array();
|
||||
|
@@ -124,8 +124,12 @@ class ClientCredentials implements GrantTypeInterface {
|
||||
|
||||
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());
|
||||
} elseif (count($scopes) === 0 && $this->authServer->getDefaultScope() !== null) {
|
||||
if (is_array($this->authServer->getDefaultScope())) {
|
||||
$scopes = $this->authServer->getDefaultScope();
|
||||
} else {
|
||||
$scopes = array($this->authServer->getDefaultScope());
|
||||
}
|
||||
}
|
||||
|
||||
$authParams['scopes'] = array();
|
||||
|
@@ -168,8 +168,12 @@ class Password implements GrantTypeInterface {
|
||||
|
||||
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());
|
||||
} elseif (count($scopes) === 0 && $this->authServer->getDefaultScope() !== null) {
|
||||
if (is_array($this->authServer->getDefaultScope())) {
|
||||
$scopes = $this->authServer->getDefaultScope();
|
||||
} else {
|
||||
$scopes = array($this->authServer->getDefaultScope());
|
||||
}
|
||||
}
|
||||
|
||||
$authParams['scopes'] = array();
|
||||
|
Reference in New Issue
Block a user