. // }}} /** * 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 App\Core\DB\DB; use League\OAuth2\Server\Entities\AccessTokenEntityInterface; use League\OAuth2\Server\Entities\ClientEntityInterface; use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; use Plugin\OAuth2\Entity; class AccessToken implements AccessTokenRepositoryInterface { public function getAccessTokenEntity(string $identifier): Entity\AccessToken { return DB::findOneBy(Entity\AccessToken::class, ['id' => $identifier]); } public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity) { DB::persist($accessTokenEntity); } public function revokeAccessToken($tokenId) { // Some logic here to revoke the access token } public function isAccessTokenRevoked($tokenId) { return false; // Access token hasn't been revoked } public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null) { $accessToken = new Entity\AccessToken(); $accessToken->setClient($clientEntity); foreach ($scopes as $scope) { $accessToken->addScope($scope); } $accessToken->setUserIdentifier($userIdentifier); return $accessToken; } }