mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-15 09:47:46 +05:30
Added requireScopes() method
This commit is contained in:
parent
3be3794311
commit
f5b6b43bef
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user