chore: make verifyAuthData private

This commit is contained in:
Maël Gangloff 2025-02-27 09:01:05 +01:00
parent 7a49adcc18
commit 3cae5d717e
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
4 changed files with 11 additions and 5 deletions

View File

@ -14,6 +14,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
@ -47,6 +48,7 @@ class ConnectorController extends AbstractController
/**
* @throws \Exception
* @throws ExceptionInterface
*/
#[Route(
path: '/api/connectors',
@ -77,9 +79,7 @@ class ConnectorController extends AbstractController
/** @var AbstractProvider $providerClient */
$providerClient = $this->locator->get($provider->getConnectorProvider());
$authData = $providerClient->verifyAuthData($connector->getAuthData());
$connector->setAuthData($authData);
$providerClient->authenticate($authData);
$connector->setAuthData($providerClient->authenticate($connector->getAuthData()));
$this->logger->info('User {username} authentication data with the {provider} provider has been validated.', [
'username' => $user->getUserIdentifier(),

View File

@ -41,6 +41,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
use Symfony\Component\Serializer\SerializerInterface;
class WatchListController extends AbstractController
@ -154,6 +155,7 @@ class WatchListController extends AbstractController
/**
* @throws \Exception
* @throws ExceptionInterface
*/
private function verifyConnector(WatchList $watchList, ?Connector $connector): void
{

View File

@ -13,6 +13,7 @@ use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Symfony\Component\Mime\Address;
use Symfony\Component\Notifier\Recipient\Recipient;
use Symfony\Component\Serializer\Exception\ExceptionInterface;
#[AsMessageHandler]
final readonly class ValidateConnectorCredentialsHandler
@ -27,6 +28,7 @@ final readonly class ValidateConnectorCredentialsHandler
/**
* @throws TransportExceptionInterface
* @throws ExceptionInterface
*/
public function __invoke(ValidateConnectorCredentials $message): void
{

View File

@ -52,7 +52,7 @@ abstract class AbstractProvider
* @throws HttpException when the user does not accept the necessary conditions
* @throws ExceptionInterface
*/
public function verifyAuthData(array $authData): array
private function verifyAuthData(array $authData): array
{
/** @var DefaultProviderDto $data */
$data = $this->serializer->denormalize($this->verifyLegalAuthData($authData), $this->dtoClass);
@ -136,10 +136,12 @@ abstract class AbstractProvider
* @throws ExceptionInterface
* @throws \Exception
*/
public function authenticate(array $authData): void
public function authenticate(array $authData): array
{
$this->authData = $this->verifyAuthData($authData);
$this->assertAuthentication();
return $this->authData;
}
abstract protected function getCachedTldList(): CacheItemInterface;