mirror of
				https://github.com/elyby/oauth2-server.git
				synced 2025-05-31 14:12:07 +05:30 
			
		
		
		
	Added requireScopes() method
This commit is contained in:
		| @@ -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(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user