diff --git a/assets/components/search/EntitiesList.tsx b/assets/components/search/EntitiesList.tsx index bf6e1fd..8ea11f7 100644 --- a/assets/components/search/EntitiesList.tsx +++ b/assets/components/search/EntitiesList.tsx @@ -1,4 +1,4 @@ -import {List, Tag, Tooltip, Typography} from 'antd' +import {Flex, List, Tag, Tooltip, Typography} from 'antd' import React from 'react' import type {Domain} from '../../utils/api' import {rdapRoleDetailTranslation, rdapRoleTranslation} from '../../utils/functions/rdapTranslation' @@ -37,7 +37,9 @@ export function EntitiesList({domain}: { domain: Domain }) { {details.organization &&
🏢 {details.organization}
} } /> - {e.roles.map(roleToTag)} + + {e.roles.map(roleToTag)} + }} /> diff --git a/config/packages/messenger.yaml b/config/packages/messenger.yaml index 38a0041..8a72323 100644 --- a/config/packages/messenger.yaml +++ b/config/packages/messenger.yaml @@ -27,6 +27,7 @@ framework: App\Message\SendDomainEventNotif: async App\Message\UpdateDomainsFromWatchlist: async App\Message\UpdateRdapServers: async + App\Message\ValidateConnectorCredentials: async # Route your messages to the transports # 'App\Message\YourMessage': async diff --git a/src/Controller/ConnectorController.php b/src/Controller/ConnectorController.php index 9d39154..da98b09 100644 --- a/src/Controller/ConnectorController.php +++ b/src/Controller/ConnectorController.php @@ -24,7 +24,7 @@ class ConnectorController extends AbstractController private readonly EntityManagerInterface $em, private readonly LoggerInterface $logger, #[Autowire(service: 'service_container')] - private ContainerInterface $locator, + private readonly ContainerInterface $locator, ) { } diff --git a/src/Message/ValidateConnectorCredentials.php b/src/Message/ValidateConnectorCredentials.php new file mode 100644 index 0000000..3383718 --- /dev/null +++ b/src/Message/ValidateConnectorCredentials.php @@ -0,0 +1,16 @@ +connectorRepository->findAll() as $connector) { + $provider = $connector->getProvider(); + + try { + if (null === $provider) { + throw new \Exception('Provider not found'); + } + + /** @var AbstractProvider $providerClient */ + $providerClient = $this->locator->get($provider->getConnectorProvider()); + $providerClient->authenticate($connector->getAuthData()); + } catch (\Exception) { + $email = $connector->getUser()->getEmail(); + $this->mailer->send( + (new ValidateConnectorCredentialsErrorNotification(new Address($email), $connector)) + ->asEmailMessage(new Recipient($email))->getMessage() + ); + } + } + } +} diff --git a/src/Notifier/ValidateConnectorCredentialsErrorNotification.php b/src/Notifier/ValidateConnectorCredentialsErrorNotification.php new file mode 100644 index 0000000..a1927da --- /dev/null +++ b/src/Notifier/ValidateConnectorCredentialsErrorNotification.php @@ -0,0 +1,33 @@ +from($this->sender) + ->to($recipient->getEmail()) + ->subject('Connector credentials error') + ->htmlTemplate('emails/errors/connector_credentials.html.twig') + ->locale('en') + ->context([ + 'connector' => $this->connector, + ])); + } +} diff --git a/src/Scheduler/ValidateConnectorCredentialsSchedule.php b/src/Scheduler/ValidateConnectorCredentialsSchedule.php new file mode 100644 index 0000000..cf64f6e --- /dev/null +++ b/src/Scheduler/ValidateConnectorCredentialsSchedule.php @@ -0,0 +1,29 @@ +add( + RecurringMessage::every('1 week', new ValidateConnectorCredentials()), + ) + ->stateful($this->cache) + ; + } +} diff --git a/templates/emails/errors/connector_credentials.twig b/templates/emails/errors/connector_credentials.twig new file mode 100644 index 0000000..b10f514 --- /dev/null +++ b/templates/emails/errors/connector_credentials.twig @@ -0,0 +1,22 @@ +{% extends "emails/base.html.twig" %} + +{% set email_color = '#f9f9f9' %} +{% set title = 'Connector Validation Failed' %} +{% block content %} +

Hello,
+ We would like to inform you that an authentication error occurred during the weekly validation of the following connector:
+ Connector ID: {{ connector.token }}
+ Connector Provider: {{ connector.provider }}
+

+

This issue indicates that the login credentials provided for the connector could not be validated. As a result, we were unable to verify the connector's validity.

+

Here are some possible causes:

+ +

+

To resolve this issue, please verify the login credentials associated with the connector and update them if necessary.

+

Thank you for your attention,
+ Sincerely,
+

+{% endblock %}