. // }}} /** * OAuth2 implementation for GNU social * * @package OAuth2 * @category API * * @author Diogo Peralta Cordeiro * @author Hugo Sales * @copyright 2022 Free Software Foundation, Inc http://www.fsf.org * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later */ namespace Plugin\OAuth2\Repository; use League\OAuth2\Server\Entities\ClientEntityInterface; use League\OAuth2\Server\Entities\ScopeEntityInterface; use League\OAuth2\Server\Repositories\ScopeRepositoryInterface; class Scope implements ScopeRepositoryInterface { /** * @return ?ScopeEntityInterface */ public function getScopeEntityByIdentifier($scopeIdentifier) { $scopes = [ 'basic' => [ 'description' => 'Basic details about you', ], 'email' => [ 'description' => 'Your email address', ], 'read' => [ 'description' => 'Read', ], 'write' => [ 'description' => 'Read', ], 'follow' => [ 'description' => 'Read', ], ]; if (\array_key_exists($scopeIdentifier, $scopes) === false) { return; } return new class($scopeIdentifier) implements ScopeEntityInterface { public function __construct(private string $identifier) { } public function getIdentifier() { return $this->identifier; } public function jsonSerialize(): mixed { return $this->getIdentifier(); } }; } public function finalizeScopes( array $scopes, $grantType, ClientEntityInterface $clientEntity, $userIdentifier = null, ) { return $scopes; } }