Allow for multiple default scopes. Fixes #42

This commit is contained in:
Alex Bilbie
2013-05-09 10:15:36 -07:00
parent 351c2e97ea
commit 7035792325
7 changed files with 145 additions and 9 deletions

View File

@@ -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)
{

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();