Added requireScopes() method

This commit is contained in:
Alex Bilbie 2013-03-04 13:10:00 +00:00
parent 3be3794311
commit f5b6b43bef
2 changed files with 30 additions and 1 deletions

View File

@ -57,6 +57,12 @@ class AuthServer
*/
static protected $grantTypes = array();
/**
* Require the "scope" parameter to be in checkAuthoriseParams()
* @var boolean
*/
protected $requireScopes = true;
/**
* The request object
* @var Util\RequestInterface
@ -164,6 +170,16 @@ class AuthServer
return (array_key_exists($identifier, self::$grantTypes));
}
/**
* Require the "scope" paremter in checkAuthoriseParams()
* @param boolean $require
* @return void
*/
public function requireScopes($require = true)
{
$this->requireScopes = $require;
}
/**
* Get the scope delimeter
*
@ -285,7 +301,7 @@ class AuthServer
if ($scopes[$i] === '') unset($scopes[$i]); // Remove any junk scopes
}
if (count($scopes) === 0) {
if ($this->requireScopes === true && count($scopes) === 0) {
throw new Exception\ClientException(sprintf(self::$exceptionMessages['invalid_request'], 'scope'), 0);
}

View File

@ -89,6 +89,19 @@ class Authorization_Server_test extends PHPUnit_Framework_TestCase
$this->assertEquals(';', $a->getScopeDelimeter());
}
public function test_requireScopes()
{
$a = $this->returnDefault();
$a->requireScopes(false);
$reflector = new ReflectionClass($a);
$requestProperty = $reflector->getProperty('requireScopes');
$requestProperty->setAccessible(true);
$v = $requestProperty->getValue($a);
$this->assertFalse($v);
}
public function test_getExpiresIn()
{
$a = $this->returnDefault();