. // }}} /** * 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 App\Util\Exception\NotFoundException; use League\OAuth2\Server\Repositories\ClientRepositoryInterface; use Plugin\OAuth2\Entity; class Client implements ClientRepositoryInterface { public function getClientEntity($clientIdentifier) { return DB::findOneBy(Entity\Client::class, ['id' => $clientIdentifier]); } public function validateClient($clientIdentifier, $clientSecret, $grantType) { try { /** @var Entity\Client $client */ $client = $this->getClientEntity($clientIdentifier); if ($client->getIsConfidential() && $clientSecret !== $client->getSecret()) { return false; } } catch (NotFoundException) { return false; } return true; } }