mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-05-31 14:12:07 +05:30
First commit of new examples
This commit is contained in:
38
examples/src/Repositories/ScopeRepository.php
Normal file
38
examples/src/Repositories/ScopeRepository.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace OAuth2ServerExamples\Repositories;
|
||||
|
||||
use League\OAuth2\Server\Entities\ScopeEntity;
|
||||
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
|
||||
|
||||
class ScopeRepository implements ScopeRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return information about a scope
|
||||
*
|
||||
* @param string $scopeIdentifier The scope identifier
|
||||
* @param string $grantType The grant type used in the request (default = "null")
|
||||
* @param string $clientId The client sending the request (default = "null")
|
||||
*
|
||||
* @return \League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface
|
||||
*/
|
||||
public function get($scopeIdentifier, $grantType = null, $clientId = null)
|
||||
{
|
||||
$scopes = [
|
||||
'basic' => [
|
||||
'description' => 'Basic details about you'
|
||||
],
|
||||
'email' => [
|
||||
'description' => 'Your email address'
|
||||
]
|
||||
];
|
||||
|
||||
if (array_key_exists($scopeIdentifier, $scopes) === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$scope = new ScopeEntity();
|
||||
$scope->setIdentifier($scopeIdentifier);
|
||||
|
||||
return $scope;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user