From 8605d9077511a84e67fe955d69b5826285a68cde Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 9 May 2024 23:53:13 -0700 Subject: [PATCH 01/39] Recovery Email blacklisted functionality --- lib/Service/UserService.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index a347655c..909a2444 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -273,6 +273,28 @@ class UserService { if ($this->isRecoveryEmailDomainDisallowed($recoveryEmail)) { throw new Exception('You cannot set an email address with a Murena domain as recovery email address.'); } + if ($this->isBlacklistedEmail($recoveryEmail)) { + throw new Exception('Recovery email is blacklisted.'); + } + } + /** + * Check if an email domain is blacklisted against a JSON list of disposable email domains. + * + * @param string $email The email address to check. + * @return bool True if the email domain is blacklisted, false otherwise. + */ + public function isBlacklistedEmail(string $email): bool { + // Fetch the JSON data from the URL + $json_url = 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json'; + $json_data = file_get_contents($json_url); + + $blacklisted_domains = json_decode($json_data, true); + + $email_domain = strtolower(substr(strrchr($email, "@"), 1)); + if (in_array($email_domain, $blacklisted_domains)) { + return true; // Email domain is blacklisted + } + return false; // Email domain is not blacklisted } /** * Add a new user to the LDAP directory. -- GitLab From 39204892a40ca6cf6b7dd0b085112d88364e5e08 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 10 May 2024 00:01:02 -0700 Subject: [PATCH 02/39] Added new Exception --- lib/Controller/AccountController.php | 5 +++++ lib/Exception/BlacklistedEmailException.php | 9 +++++++++ lib/Service/UserService.php | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 lib/Exception/BlacklistedEmailException.php diff --git a/lib/Controller/AccountController.php b/lib/Controller/AccountController.php index 35a14372..8af47485 100644 --- a/lib/Controller/AccountController.php +++ b/lib/Controller/AccountController.php @@ -9,6 +9,7 @@ namespace OCA\EcloudAccounts\Controller; use Exception; use OCA\EcloudAccounts\AppInfo\Application; use OCA\EcloudAccounts\Exception\AddUsernameToCommonStoreException; +use OCA\EcloudAccounts\Exception\BlacklistedEmailException; use OCA\EcloudAccounts\Exception\LDAPUserCreationException; use OCA\EcloudAccounts\Service\CaptchaService; use OCA\EcloudAccounts\Service\NewsLetterService; @@ -166,6 +167,10 @@ class AccountController extends Controller { $this->logger->logException($e, ['app' => Application::APP_ID]); $response->setData(['message' => 'A server-side error occurred while processing your request! Please try again later.', 'success' => false]); $response->setStatus(500); + } catch (BlacklistedEmailException | Error $e) { + $this->logger->logException($e, ['app' => Application::APP_ID]); + $response->setData(['message' => $e->getMessage(), 'success' => false]); + $response->setStatus(500); } catch (AddUsernameToCommonStoreException $e) { $this->logger->logException($e, ['app' => Application::APP_ID]); $response->setStatus(200); diff --git a/lib/Exception/BlacklistedEmailException.php b/lib/Exception/BlacklistedEmailException.php new file mode 100644 index 00000000..a435268b --- /dev/null +++ b/lib/Exception/BlacklistedEmailException.php @@ -0,0 +1,9 @@ +isBlacklistedEmail($recoveryEmail)) { - throw new Exception('Recovery email is blacklisted.'); + throw new BlacklistedEmailException('Recovery email is blacklisted.'); } } /** -- GitLab From eccbe65ff3abf7dd485fb59d8e3d7637174d32fd Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 10 May 2024 00:07:07 -0700 Subject: [PATCH 03/39] Added new Exception --- lib/Service/UserService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index 96d75a27..87b2c55a 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -275,7 +275,7 @@ class UserService { throw new Exception('You cannot set an email address with a Murena domain as recovery email address.'); } if ($this->isBlacklistedEmail($recoveryEmail)) { - throw new BlacklistedEmailException('Recovery email is blacklisted.'); + throw new BlacklistedEmailException('The entered recovery email domain is blacklisted. Please try another.'); } } /** -- GitLab From 0159c11af58c51cc2278a8c91e5a858a5bbb47f6 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 10 May 2024 00:18:39 -0700 Subject: [PATCH 04/39] translation added --- l10n/de.js | 3 ++- l10n/de.json | 3 ++- l10n/en.js | 3 ++- l10n/en.json | 3 ++- l10n/es.js | 3 ++- l10n/es.json | 3 ++- l10n/fr.js | 3 ++- l10n/fr.json | 3 ++- l10n/it.js | 3 ++- l10n/it.json | 3 ++- 10 files changed, 20 insertions(+), 10 deletions(-) diff --git a/l10n/de.js b/l10n/de.js index 373b849a..893a1479 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -84,6 +84,7 @@ OC.L10N.register( "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", "Captcha is not verified!": "Captcha wird nicht überprüft!", "A server-side error occurred while processing your request! Please try again later.": "Ein serverseitiger Fehler ist bei der Bearbeitung Ihrer Anfrage aufgetreten! Bitte versuchen Sie es später noch einmal.", - "An error occurred while creating your account!": "Beim Anlegen Ihres Kontos ist ein Fehler aufgetreten!" + "An error occurred while creating your account!": "Beim Anlegen Ihres Kontos ist ein Fehler aufgetreten!", + "The entered recovery email domain is blacklisted. Please try another.": "Die eingegebene Wiederherstellungs-E-Mail-Domäne steht auf der schwarzen Liste. Bitte versuchen Sie eine andere." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/de.json b/l10n/de.json index ea9ce7da..b6509a5e 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -82,7 +82,8 @@ "You cannot set an email address with a Murena domain as recovery email address.": "Sie können keine E-Mail-Adresse mit einer Murena-Domäne als Wiederherstellungs-E-Mail-Adresse festlegen.", "Captcha is not verified!": "Captcha wird nicht überprüft!", "A server-side error occurred while processing your request! Please try again later.": "Ein serverseitiger Fehler ist bei der Bearbeitung Ihrer Anfrage aufgetreten! Bitte versuchen Sie es später noch einmal.", - "An error occurred while creating your account!": "Beim Anlegen Ihres Kontos ist ein Fehler aufgetreten!" + "An error occurred while creating your account!": "Beim Anlegen Ihres Kontos ist ein Fehler aufgetreten!", + "The entered recovery email domain is blacklisted. Please try another.": "Die eingegebene Wiederherstellungs-E-Mail-Domäne steht auf der schwarzen Liste. Bitte versuchen Sie eine andere." }, "pluralForm": "nplurals=2; plural=(n != 1);" } diff --git a/l10n/en.js b/l10n/en.js index 667cbc32..dee2faae 100644 --- a/l10n/en.js +++ b/l10n/en.js @@ -88,6 +88,7 @@ OC.L10N.register( "You cannot set an email address with a Murena domain as recovery email address.": "You cannot set an email address with a Murena domain as recovery email address.", "Captcha is not verified!": "Captcha is not verified!", "A server-side error occurred while processing your request! Please try again later.": "A server-side error occurred while processing your request! Please try again later.", - "An error occurred while creating your account!": "An error occurred while creating your account!" + "An error occurred while creating your account!": "An error occurred while creating your account!", + "The entered recovery email domain is blacklisted. Please try another.": "The entered recovery email domain is blacklisted. Please try another." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/en.json b/l10n/en.json index cfef1665..df4c8dbc 100644 --- a/l10n/en.json +++ b/l10n/en.json @@ -84,7 +84,8 @@ "You cannot set an email address with a Murena domain as recovery email address.": "You cannot set an email address with a Murena domain as recovery email address.", "Captcha is not verified!": "Captcha is not verified!", "A server-side error occurred while processing your request! Please try again later.": "A server-side error occurred while processing your request! Please try again later.", - "An error occurred while creating your account!": "An error occurred while creating your account!" + "An error occurred while creating your account!": "An error occurred while creating your account!", + "The entered recovery email domain is blacklisted. Please try another.": "The entered recovery email domain is blacklisted. Please try another." }, "pluralForm": "nplurals=2; plural=(n != 1);" } diff --git a/l10n/es.js b/l10n/es.js index e3108cf2..2daeaf56 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -86,6 +86,7 @@ OC.L10N.register( "You cannot set an email address with a Murena domain as recovery email address.": "No puede establecer una dirección de correo electrónico con un dominio de Murena como dirección de correo electrónico de recuperación.", "Captcha is not verified!": "¡Captcha no está verificado!", "A server-side error occurred while processing your request! Please try again later.": "Hubo un error en el servidor al procesar tu solicitud. Por favor, inténtalo más tarde.", - "An error occurred while creating your account!": "¡Hubo un error creando tu cuenta!" + "An error occurred while creating your account!": "¡Hubo un error creando tu cuenta!", + "The entered recovery email domain is blacklisted. Please try another.": "El dominio de correo electrónico de recuperación introducido está en la lista negra. Pruebe con otro." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/es.json b/l10n/es.json index defa25be..a39ebc91 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -85,7 +85,8 @@ "You cannot set an email address with a Murena domain as recovery email address.": "No puede establecer una dirección de correo electrónico con un dominio de Murena como dirección de correo electrónico de recuperación.", "Captcha is not verified!": "¡Captcha no está verificado!", "A server-side error occurred while processing your request! Please try again later.": "Hubo un error en el servidor al procesar tu solicitud. Por favor, inténtalo más tarde.", - "An error occurred while creating your account!": "¡Hubo un error creando tu cuenta!" + "An error occurred while creating your account!": "¡Hubo un error creando tu cuenta!", + "The entered recovery email domain is blacklisted. Please try another.": "El dominio de correo electrónico de recuperación introducido está en la lista negra. Pruebe con otro." }, "pluralForm": "nplurals=2; plural=(n != 1);" } diff --git a/l10n/fr.js b/l10n/fr.js index 10f15144..dfe24638 100644 --- a/l10n/fr.js +++ b/l10n/fr.js @@ -85,6 +85,7 @@ OC.L10N.register( "You cannot set an email address with a Murena domain as recovery email address.": "Vous ne pouvez pas définir une adresse électronique avec un domaine Murena comme adresse électronique de récupération.", "Captcha is not verified!": "Captcha n'est pas vérifié !", "A server-side error occurred while processing your request! Please try again later.": "Erreur du serveur dans la gestion de votre demande ! Merci d'essayer ultérieurement.", - "An error occurred while creating your account!": "Une erreur s'est produite lors de la création de votre compte!" + "An error occurred while creating your account!": "Une erreur s'est produite lors de la création de votre compte!", + "The entered recovery email domain is blacklisted. Please try another.": "Le domaine de l'email de récupération saisi est sur liste noire. Veuillez en essayer un autre." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/fr.json b/l10n/fr.json index e26fdac3..5e64e303 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -84,7 +84,8 @@ "You cannot set an email address with a Murena domain as recovery email address.": "Vous ne pouvez pas définir une adresse électronique avec un domaine Murena comme adresse électronique de récupération.", "Captcha is not verified!": "Captcha n'est pas vérifié !", "A server-side error occurred while processing your request! Please try again later.": "Erreur du serveur dans la gestion de votre demande ! Merci d'essayer ultérieurement.", - "An error occurred while creating your account!": "Une erreur s'est produite lors de la création de votre compte!" + "An error occurred while creating your account!": "Une erreur s'est produite lors de la création de votre compte!", + "The entered recovery email domain is blacklisted. Please try another.": "Le domaine de l'email de récupération saisi est sur liste noire. Veuillez en essayer un autre." }, "pluralForm": "nplurals=2; plural=(n != 1);" } diff --git a/l10n/it.js b/l10n/it.js index 7d330622..e16ae713 100644 --- a/l10n/it.js +++ b/l10n/it.js @@ -85,6 +85,7 @@ OC.L10N.register( "You cannot set an email address with a Murena domain as recovery email address.": "Non è possibile impostare un indirizzo e-mail con un dominio Murena come indirizzo e-mail di recupero.", "Captcha is not verified!": "Il Captcha non è verificato!", "A server-side error occurred while processing your request! Please try again later.": "Si è verificato un errore lato server nel processare la tua richiesta! Ritenta più tardi.", - "An error occurred while creating your account!": "Si è verificato un errore nella creazione dell'account!" + "An error occurred while creating your account!": "Si è verificato un errore nella creazione dell'account!", + "The entered recovery email domain is blacklisted. Please try another.": "Il dominio e-mail di recupero inserito è nella lista nera. Provare con un altro." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/it.json b/l10n/it.json index 824bd43a..a2a9675b 100644 --- a/l10n/it.json +++ b/l10n/it.json @@ -80,7 +80,8 @@ "You cannot set an email address with a Murena domain as recovery email address.": "Non è possibile impostare un indirizzo e-mail con un dominio Murena come indirizzo e-mail di recupero.", "Captcha is not verified!": "Il Captcha non è verificato!", "A server-side error occurred while processing your request! Please try again later.": "Si è verificato un errore lato server nel processare la tua richiesta! Ritenta più tardi.", - "An error occurred while creating your account!": "Si è verificato un errore nella creazione dell'account!" + "An error occurred while creating your account!": "Si è verificato un errore nella creazione dell'account!", + "The entered recovery email domain is blacklisted. Please try another.": "Il dominio e-mail di recupero inserito è nella lista nera. Provare con un altro." }, "pluralForm": "nplurals=2; plural=(n != 1);" } -- GitLab From a17df6d41613a7f59562281c312cb6b317e60ff3 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 22:13:13 -0700 Subject: [PATCH 05/39] added blacklist crons --- lib/Command/MigrateBlacklistedDomains.php | 42 +++++++++++++++++++++++ lib/Db/BlacklistedDomainMapper.php | 42 +++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 lib/Command/MigrateBlacklistedDomains.php create mode 100644 lib/Db/BlacklistedDomainMapper.php diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php new file mode 100644 index 00000000..10498a57 --- /dev/null +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -0,0 +1,42 @@ +blacklistedDomainMapper = $blacklistedDomainMapper; + parent::__construct(); + } + + protected function configure(): void { + $this + ->setName('ecloud-accounts:blacklisted-domains') + ->setDescription('Migrate blacklisted domains to db table.'); + } + protected function execute(): int { + try { + $this->migrateBlacklistedDomains(); + return 0; + } catch (\Exception $e) { + return 1; + } + } + + /** + * Migrate + * + * @return void + */ + private function migrateBlacklistedDomains() : void { + $this->blacklistedDomainMapper->updateBlacklistedDomains(); + } +} diff --git a/lib/Db/BlacklistedDomainMapper.php b/lib/Db/BlacklistedDomainMapper.php new file mode 100644 index 00000000..a47596c9 --- /dev/null +++ b/lib/Db/BlacklistedDomainMapper.php @@ -0,0 +1,42 @@ +db = $db; + $this->config = $config; + $this->logger = $logger; + } + public function updateBlacklistedDomains() { + $json_url = 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json'; + $json_data = file_get_contents($json_url); + + $this->config->setAppValue('core', 'blacklisted_domains', $json_data); + + $blacklisted_domains = json_decode($json_data, true); + try { + $dbTablePrefix = $this->config->getSystemValue('dbtableprefix', ''); + $params = []; + $blacklistedDomainTable = $dbTablePrefix . 'blacklisted_domains'; + $query = 'INSERT INTO ' . $blacklistedDomainTable . ' (domain) VALUES (?)'; + + foreach ($blacklisted_domains as $domain) { + $params[] = $domain; + $this->db->executeQuery($query, $params); + } + + } catch (Exception $e) { + $this->logger->error('Error updating mailbox usage! ' . $e->getMessage()); + } + } +} -- GitLab From 788e173ee446fc6ead0fddc775f8108e15f132c3 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 22:14:52 -0700 Subject: [PATCH 06/39] added blacklist crons --- lib/Db/BlacklistedDomainMapper.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib/Db/BlacklistedDomainMapper.php b/lib/Db/BlacklistedDomainMapper.php index a47596c9..2e326bfa 100644 --- a/lib/Db/BlacklistedDomainMapper.php +++ b/lib/Db/BlacklistedDomainMapper.php @@ -20,23 +20,6 @@ class BlacklistedDomainMapper { public function updateBlacklistedDomains() { $json_url = 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json'; $json_data = file_get_contents($json_url); - $this->config->setAppValue('core', 'blacklisted_domains', $json_data); - - $blacklisted_domains = json_decode($json_data, true); - try { - $dbTablePrefix = $this->config->getSystemValue('dbtableprefix', ''); - $params = []; - $blacklistedDomainTable = $dbTablePrefix . 'blacklisted_domains'; - $query = 'INSERT INTO ' . $blacklistedDomainTable . ' (domain) VALUES (?)'; - - foreach ($blacklisted_domains as $domain) { - $params[] = $domain; - $this->db->executeQuery($query, $params); - } - - } catch (Exception $e) { - $this->logger->error('Error updating mailbox usage! ' . $e->getMessage()); - } } } -- GitLab From 83e59af13edc4232c833f10f00d7a78c7f0101ef Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 22:16:02 -0700 Subject: [PATCH 07/39] added blacklist crons --- lib/Command/MigrateBlacklistedDomains.php | 2 -- lib/Db/BlacklistedDomainMapper.php | 9 +-------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index 10498a57..843c3ba7 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace OCA\EcloudAccounts\Command; -use OCA\EcloudAccounts\Db\WebmailMapper; use Symfony\Component\Console\Command\Command; use OCA\EcloudAccounts\Db\BlacklistedDomainMapper; @@ -30,7 +29,6 @@ class MigrateWebmailAddressbooks extends Command { return 1; } } - /** * Migrate * diff --git a/lib/Db/BlacklistedDomainMapper.php b/lib/Db/BlacklistedDomainMapper.php index 2e326bfa..8bef3830 100644 --- a/lib/Db/BlacklistedDomainMapper.php +++ b/lib/Db/BlacklistedDomainMapper.php @@ -2,20 +2,13 @@ namespace OCA\EcloudAccounts\Db; -use Exception; use OCP\IConfig; -use OCP\IDBConnection; -use OCP\ILogger; class BlacklistedDomainMapper { - private $db; private $config; - private $logger; - public function __construct(IDBConnection $db, IConfig $config, ILogger $logger) { - $this->db = $db; + public function __construct(IConfig $config) { $this->config = $config; - $this->logger = $logger; } public function updateBlacklistedDomains() { $json_url = 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json'; -- GitLab From 341ed63b257a507785f0d1607a4a1240d3d656b6 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 22:16:26 -0700 Subject: [PATCH 08/39] lint --- lib/Command/MigrateBlacklistedDomains.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index 843c3ba7..89f17eeb 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace OCA\EcloudAccounts\Command; -use Symfony\Component\Console\Command\Command; use OCA\EcloudAccounts\Db\BlacklistedDomainMapper; +use Symfony\Component\Console\Command\Command; class MigrateWebmailAddressbooks extends Command { @@ -30,7 +30,7 @@ class MigrateWebmailAddressbooks extends Command { } } /** - * Migrate + * Migrate * * @return void */ -- GitLab From 4aa975b4fdfa534e615c8c0c47855ec288c605cd Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 22:21:02 -0700 Subject: [PATCH 09/39] app id added --- lib/Db/BlacklistedDomainMapper.php | 3 ++- lib/Service/UserService.php | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Db/BlacklistedDomainMapper.php b/lib/Db/BlacklistedDomainMapper.php index 8bef3830..c25dead2 100644 --- a/lib/Db/BlacklistedDomainMapper.php +++ b/lib/Db/BlacklistedDomainMapper.php @@ -2,6 +2,7 @@ namespace OCA\EcloudAccounts\Db; +use OCA\EcloudAccounts\AppInfo\Application; use OCP\IConfig; class BlacklistedDomainMapper { @@ -13,6 +14,6 @@ class BlacklistedDomainMapper { public function updateBlacklistedDomains() { $json_url = 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json'; $json_data = file_get_contents($json_url); - $this->config->setAppValue('core', 'blacklisted_domains', $json_data); + $this->config->setAppValue(Application::APP_ID, 'blacklisted_domains', $json_data); } } diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index 87b2c55a..2d3d282b 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -285,10 +285,8 @@ class UserService { * @return bool True if the email domain is blacklisted, false otherwise. */ public function isBlacklistedEmail(string $email): bool { - // Fetch the JSON data from the URL - $json_url = 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json'; - $json_data = file_get_contents($json_url); + $json_data = $this->config->getAppValue(Application::APP_ID, 'blacklisted_domains'); $blacklisted_domains = json_decode($json_data, true); $email_domain = strtolower(substr(strrchr($email, "@"), 1)); -- GitLab From 16245350946c3dd73b96908ddd79b2590507b8f7 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 22:36:48 -0700 Subject: [PATCH 10/39] added command --- appinfo/info.xml | 1 + lib/Command/MigrateBlacklistedDomains.php | 2 +- lib/Db/BlacklistedDomainMapper.php | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 351006aa..aef24924 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -27,5 +27,6 @@ OCA\EcloudAccounts\Command\Migrate2FASecrets OCA\EcloudAccounts\Command\MigrateWebmailAddressbooks + OCA\EcloudAccounts\Command\MigrateBlacklistedDomains diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index 89f17eeb..8f6d5675 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -7,7 +7,7 @@ namespace OCA\EcloudAccounts\Command; use OCA\EcloudAccounts\Db\BlacklistedDomainMapper; use Symfony\Component\Console\Command\Command; -class MigrateWebmailAddressbooks extends Command { +class MigrateBlacklistedDomains extends Command { private BlacklistedDomainMapper $blacklistedDomainMapper; diff --git a/lib/Db/BlacklistedDomainMapper.php b/lib/Db/BlacklistedDomainMapper.php index c25dead2..d7b9bf1c 100644 --- a/lib/Db/BlacklistedDomainMapper.php +++ b/lib/Db/BlacklistedDomainMapper.php @@ -12,8 +12,8 @@ class BlacklistedDomainMapper { $this->config = $config; } public function updateBlacklistedDomains() { - $json_url = 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json'; - $json_data = file_get_contents($json_url); + $blacklisted_domain_url = 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json'; + $json_data = file_get_contents($blacklisted_domain_url); $this->config->setAppValue(Application::APP_ID, 'blacklisted_domains', $json_data); } } -- GitLab From 4302db7f34629feb42ca952ede2ff92081f76619 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 22:38:06 -0700 Subject: [PATCH 11/39] added command --- lib/Command/MigrateBlacklistedDomains.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index 8f6d5675..9dd9ce4c 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -18,7 +18,7 @@ class MigrateBlacklistedDomains extends Command { protected function configure(): void { $this - ->setName('ecloud-accounts:blacklisted-domains') + ->setName('ecloud-accounts:migrate-blacklisted-domains') ->setDescription('Migrate blacklisted domains to db table.'); } protected function execute(): int { -- GitLab From e45ce63061b37f51a7f82947a6551121537b4e5a Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 22:43:29 -0700 Subject: [PATCH 12/39] added command #2 --- lib/Command/MigrateBlacklistedDomains.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index 9dd9ce4c..0c6d5c36 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -6,10 +6,13 @@ namespace OCA\EcloudAccounts\Command; use OCA\EcloudAccounts\Db\BlacklistedDomainMapper; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; class MigrateBlacklistedDomains extends Command { private BlacklistedDomainMapper $blacklistedDomainMapper; + private OutputInterface $commandOutput; public function __construct(BlacklistedDomainMapper $blacklistedDomainMapper) { $this->blacklistedDomainMapper = $blacklistedDomainMapper; @@ -21,12 +24,11 @@ class MigrateBlacklistedDomains extends Command { ->setName('ecloud-accounts:migrate-blacklisted-domains') ->setDescription('Migrate blacklisted domains to db table.'); } - protected function execute(): int { + protected function execute(InputInterface $input, OutputInterface $output): int { try { + $this->commandOutput = $output; $this->migrateBlacklistedDomains(); - return 0; } catch (\Exception $e) { - return 1; } } /** @@ -36,5 +38,6 @@ class MigrateBlacklistedDomains extends Command { */ private function migrateBlacklistedDomains() : void { $this->blacklistedDomainMapper->updateBlacklistedDomains(); + $this->commandOutput->writeln('Migrated blacklisted domains successfully.'); } } -- GitLab From c24aedb250a5c25baaf7ebed28b211508bc31491 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 22:45:58 -0700 Subject: [PATCH 13/39] added command #3 --- lib/Command/MigrateBlacklistedDomains.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index 0c6d5c36..14186369 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -7,6 +7,7 @@ namespace OCA\EcloudAccounts\Command; use OCA\EcloudAccounts\Db\BlacklistedDomainMapper; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class MigrateBlacklistedDomains extends Command { @@ -26,9 +27,10 @@ class MigrateBlacklistedDomains extends Command { } protected function execute(InputInterface $input, OutputInterface $output): int { try { - $this->commandOutput = $output; $this->migrateBlacklistedDomains(); + return 0; } catch (\Exception $e) { + return 1; } } /** @@ -38,6 +40,5 @@ class MigrateBlacklistedDomains extends Command { */ private function migrateBlacklistedDomains() : void { $this->blacklistedDomainMapper->updateBlacklistedDomains(); - $this->commandOutput->writeln('Migrated blacklisted domains successfully.'); } } -- GitLab From 3353f7d0c677575f3e3d84fbc3286dd109904325 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 22:46:39 -0700 Subject: [PATCH 14/39] added command #4 --- lib/Command/MigrateBlacklistedDomains.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index 14186369..2f64c213 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -7,7 +7,6 @@ namespace OCA\EcloudAccounts\Command; use OCA\EcloudAccounts\Db\BlacklistedDomainMapper; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class MigrateBlacklistedDomains extends Command { -- GitLab From d6ee222dd9603e6ea9ca094eef66cb5a546430ec Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 22:51:56 -0700 Subject: [PATCH 15/39] added command #5 --- lib/Command/MigrateBlacklistedDomains.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index 2f64c213..08cc85c0 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -10,9 +10,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class MigrateBlacklistedDomains extends Command { - - private BlacklistedDomainMapper $blacklistedDomainMapper; private OutputInterface $commandOutput; + private BlacklistedDomainMapper $blacklistedDomainMapper; public function __construct(BlacklistedDomainMapper $blacklistedDomainMapper) { $this->blacklistedDomainMapper = $blacklistedDomainMapper; @@ -22,22 +21,30 @@ class MigrateBlacklistedDomains extends Command { protected function configure(): void { $this ->setName('ecloud-accounts:migrate-blacklisted-domains') - ->setDescription('Migrate blacklisted domains to db table.'); + ->setDescription('Migrates 2FA secrets to SSO database'); } + protected function execute(InputInterface $input, OutputInterface $output): int { try { + $this->commandOutput = $output; $this->migrateBlacklistedDomains(); return 0; } catch (\Exception $e) { + $this->commandOutput->writeln($e->getMessage()); return 1; } } + /** - * Migrate + * Migrate user secrets to the SSO database * * @return void */ private function migrateBlacklistedDomains() : void { - $this->blacklistedDomainMapper->updateBlacklistedDomains(); + try { + $this->blacklistedDomainMapper->updateBlacklistedDomains(); + } catch (\Exception $e) { + $this->commandOutput->writeln('Error migrating domains. message: ' . $e->getMessage()); + } } } -- GitLab From 5eb6f3c233212185e1d1200dc3f4b9c4a2e83b27 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:00:23 -0700 Subject: [PATCH 16/39] added command #6 --- lib/Command/MigrateBlacklistedDomains.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index 08cc85c0..157ed82b 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -25,14 +25,7 @@ class MigrateBlacklistedDomains extends Command { } protected function execute(InputInterface $input, OutputInterface $output): int { - try { - $this->commandOutput = $output; - $this->migrateBlacklistedDomains(); - return 0; - } catch (\Exception $e) { - $this->commandOutput->writeln($e->getMessage()); - return 1; - } + $this->migrateBlacklistedDomains(); } /** -- GitLab From d0c89a55ea546c7c8e882fecf62c2456dbd9b9fe Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:03:26 -0700 Subject: [PATCH 17/39] added command #7 --- lib/Command/MigrateBlacklistedDomains.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index 157ed82b..c3b7ab28 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -21,7 +21,14 @@ class MigrateBlacklistedDomains extends Command { protected function configure(): void { $this ->setName('ecloud-accounts:migrate-blacklisted-domains') - ->setDescription('Migrates 2FA secrets to SSO database'); + ->setDescription('Migrates 2FA secrets to SSO database') + ->addOption( + 'users', + null, + InputOption::VALUE_OPTIONAL, + 'comma separated list of users', + '' + ); } protected function execute(InputInterface $input, OutputInterface $output): int { -- GitLab From e64afbdf1a076f452938b9945cfe42022264c334 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:07:47 -0700 Subject: [PATCH 18/39] added command #8 --- lib/Command/MigrateBlacklistedDomains.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index c3b7ab28..2a37d505 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -21,7 +21,7 @@ class MigrateBlacklistedDomains extends Command { protected function configure(): void { $this ->setName('ecloud-accounts:migrate-blacklisted-domains') - ->setDescription('Migrates 2FA secrets to SSO database') + ->setDescription('Migrates blacklisted domains') ->addOption( 'users', null, @@ -32,19 +32,6 @@ class MigrateBlacklistedDomains extends Command { } protected function execute(InputInterface $input, OutputInterface $output): int { - $this->migrateBlacklistedDomains(); - } - - /** - * Migrate user secrets to the SSO database - * - * @return void - */ - private function migrateBlacklistedDomains() : void { - try { - $this->blacklistedDomainMapper->updateBlacklistedDomains(); - } catch (\Exception $e) { - $this->commandOutput->writeln('Error migrating domains. message: ' . $e->getMessage()); - } + $this->blacklistedDomainMapper->updateBlacklistedDomains(); } } -- GitLab From 2a2d28e4127976c9c8bd1c5a1d68e6abc92804db Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:11:29 -0700 Subject: [PATCH 19/39] added command #9 --- lib/Command/MigrateBlacklistedDomains.php | 47 +++++++++++++++++++---- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index 2a37d505..98b4171b 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -4,24 +4,28 @@ declare(strict_types=1); namespace OCA\EcloudAccounts\Command; -use OCA\EcloudAccounts\Db\BlacklistedDomainMapper; +use OCA\EcloudAccounts\Db\TwoFactorMapper; +use OCA\EcloudAccounts\Service\SSOService; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class MigrateBlacklistedDomains extends Command { + private SSOService $ssoService; + private TwoFactorMapper $twoFactorMapper; private OutputInterface $commandOutput; - private BlacklistedDomainMapper $blacklistedDomainMapper; - public function __construct(BlacklistedDomainMapper $blacklistedDomainMapper) { - $this->blacklistedDomainMapper = $blacklistedDomainMapper; + public function __construct(SSOService $ssoService, TwoFactorMapper $twoFactorMapper) { + $this->ssoService = $ssoService; + $this->twoFactorMapper = $twoFactorMapper; parent::__construct(); } protected function configure(): void { $this - ->setName('ecloud-accounts:migrate-blacklisted-domains') - ->setDescription('Migrates blacklisted domains') + ->setName('ecloud-accounts:migrate-2fa-secrets') + ->setDescription('Migrates 2FA secrets to SSO database') ->addOption( 'users', null, @@ -32,6 +36,35 @@ class MigrateBlacklistedDomains extends Command { } protected function execute(InputInterface $input, OutputInterface $output): int { - $this->blacklistedDomainMapper->updateBlacklistedDomains(); + try { + $this->commandOutput = $output; + $usernames = []; + $usernameList = $input->getOption('users'); + if (!empty($usernameList)) { + $usernames = explode(',', $usernameList); + } + $this->migrateUsers($usernames); + return 0; + } catch (\Exception $e) { + $this->commandOutput->writeln($e->getMessage()); + return 1; + } + } + + /** + * Migrate user secrets to the SSO database + * + * @return void + */ + private function migrateUsers(array $usernames = []) : void { + $entries = $this->twoFactorMapper->getEntries($usernames); + foreach ($entries as $entry) { + try { + $this->ssoService->migrateCredential($entry['username'], $entry['secret']); + } catch (\Exception $e) { + $this->commandOutput->writeln('Error inserting entry for user ' . $entry['username'] . ' message: ' . $e->getMessage()); + continue; + } + } } } -- GitLab From 06caaa12c6fb436476a98e5c9d4dfc8e5645c649 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:15:47 -0700 Subject: [PATCH 20/39] added command #10 --- appinfo/info.xml | 1 - lib/Command/MigrateBlacklistedDomains.php | 70 ----------------------- 2 files changed, 71 deletions(-) delete mode 100644 lib/Command/MigrateBlacklistedDomains.php diff --git a/appinfo/info.xml b/appinfo/info.xml index aef24924..351006aa 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -27,6 +27,5 @@ OCA\EcloudAccounts\Command\Migrate2FASecrets OCA\EcloudAccounts\Command\MigrateWebmailAddressbooks - OCA\EcloudAccounts\Command\MigrateBlacklistedDomains diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php deleted file mode 100644 index 98b4171b..00000000 --- a/lib/Command/MigrateBlacklistedDomains.php +++ /dev/null @@ -1,70 +0,0 @@ -ssoService = $ssoService; - $this->twoFactorMapper = $twoFactorMapper; - parent::__construct(); - } - - protected function configure(): void { - $this - ->setName('ecloud-accounts:migrate-2fa-secrets') - ->setDescription('Migrates 2FA secrets to SSO database') - ->addOption( - 'users', - null, - InputOption::VALUE_OPTIONAL, - 'comma separated list of users', - '' - ); - } - - protected function execute(InputInterface $input, OutputInterface $output): int { - try { - $this->commandOutput = $output; - $usernames = []; - $usernameList = $input->getOption('users'); - if (!empty($usernameList)) { - $usernames = explode(',', $usernameList); - } - $this->migrateUsers($usernames); - return 0; - } catch (\Exception $e) { - $this->commandOutput->writeln($e->getMessage()); - return 1; - } - } - - /** - * Migrate user secrets to the SSO database - * - * @return void - */ - private function migrateUsers(array $usernames = []) : void { - $entries = $this->twoFactorMapper->getEntries($usernames); - foreach ($entries as $entry) { - try { - $this->ssoService->migrateCredential($entry['username'], $entry['secret']); - } catch (\Exception $e) { - $this->commandOutput->writeln('Error inserting entry for user ' . $entry['username'] . ' message: ' . $e->getMessage()); - continue; - } - } - } -} -- GitLab From 97bf6310136f04753dad3063e1f7d934426ca559 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:21:09 -0700 Subject: [PATCH 21/39] added command #10 --- appinfo/info.xml | 1 + lib/Command/MigrateBlacklistedDomains.php | 30 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 lib/Command/MigrateBlacklistedDomains.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 351006aa..aef24924 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -27,5 +27,6 @@ OCA\EcloudAccounts\Command\Migrate2FASecrets OCA\EcloudAccounts\Command\MigrateWebmailAddressbooks + OCA\EcloudAccounts\Command\MigrateBlacklistedDomains diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php new file mode 100644 index 00000000..80d7e673 --- /dev/null +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -0,0 +1,30 @@ +blacklistedDomainMapper = $blacklistedDomainMapper; + parent::__construct(); + } + + protected function configure(): void { + $this + ->setName('ecloud-accounts:migrate-blacklisted-domains') + ->setDescription('Migrates blacklisted domains'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $this->blacklistedDomainMapper->updateBlacklistedDomains(); + } +} -- GitLab From e05e1e1e52302525ae53b8bbd04bbf6bcbc63b83 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:24:20 -0700 Subject: [PATCH 22/39] added command #11 --- appinfo/info.xml | 2 +- ...ateBlacklistedDomains.php => SyncBlacklistedDomains.php} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename lib/Command/{MigrateBlacklistedDomains.php => SyncBlacklistedDomains.php} (82%) diff --git a/appinfo/info.xml b/appinfo/info.xml index aef24924..6b417bf1 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -27,6 +27,6 @@ OCA\EcloudAccounts\Command\Migrate2FASecrets OCA\EcloudAccounts\Command\MigrateWebmailAddressbooks - OCA\EcloudAccounts\Command\MigrateBlacklistedDomains + OCA\EcloudAccounts\Command\SyncBlacklistedDomains diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/SyncBlacklistedDomains.php similarity index 82% rename from lib/Command/MigrateBlacklistedDomains.php rename to lib/Command/SyncBlacklistedDomains.php index 80d7e673..8b6b6264 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/SyncBlacklistedDomains.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class MigrateBlacklistedDomains extends Command { +class SyncBlacklistedDomains extends Command { private OutputInterface $commandOutput; private BlacklistedDomainMapper $blacklistedDomainMapper; @@ -20,8 +20,8 @@ class MigrateBlacklistedDomains extends Command { protected function configure(): void { $this - ->setName('ecloud-accounts:migrate-blacklisted-domains') - ->setDescription('Migrates blacklisted domains'); + ->setName('ecloud-accounts:sync-blacklisted-domains') + ->setDescription('Sync blacklisted domains'); } protected function execute(InputInterface $input, OutputInterface $output): int { -- GitLab From d457696bca29feb40850cddc692cc89cfeed3d54 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:26:46 -0700 Subject: [PATCH 23/39] added command #11 --- appinfo/info.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 6b417bf1..351006aa 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -27,6 +27,5 @@ OCA\EcloudAccounts\Command\Migrate2FASecrets OCA\EcloudAccounts\Command\MigrateWebmailAddressbooks - OCA\EcloudAccounts\Command\SyncBlacklistedDomains -- GitLab From e4733fc2ca7ab0f2ed105a822ed2506857d20910 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:30:19 -0700 Subject: [PATCH 24/39] added command #11 --- lib/Command/SyncBlacklistedDomains.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Command/SyncBlacklistedDomains.php b/lib/Command/SyncBlacklistedDomains.php index 8b6b6264..8b1edee4 100644 --- a/lib/Command/SyncBlacklistedDomains.php +++ b/lib/Command/SyncBlacklistedDomains.php @@ -10,7 +10,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class SyncBlacklistedDomains extends Command { - private OutputInterface $commandOutput; private BlacklistedDomainMapper $blacklistedDomainMapper; public function __construct(BlacklistedDomainMapper $blacklistedDomainMapper) { @@ -26,5 +25,6 @@ class SyncBlacklistedDomains extends Command { protected function execute(InputInterface $input, OutputInterface $output): int { $this->blacklistedDomainMapper->updateBlacklistedDomains(); + return 1; } } -- GitLab From 80a09515e966f8d28d43868c069557df92df2714 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:33:59 -0700 Subject: [PATCH 25/39] added command #11 --- lib/Command/SyncBlacklistedDomains.php | 30 -------------------------- 1 file changed, 30 deletions(-) delete mode 100644 lib/Command/SyncBlacklistedDomains.php diff --git a/lib/Command/SyncBlacklistedDomains.php b/lib/Command/SyncBlacklistedDomains.php deleted file mode 100644 index 8b1edee4..00000000 --- a/lib/Command/SyncBlacklistedDomains.php +++ /dev/null @@ -1,30 +0,0 @@ -blacklistedDomainMapper = $blacklistedDomainMapper; - parent::__construct(); - } - - protected function configure(): void { - $this - ->setName('ecloud-accounts:sync-blacklisted-domains') - ->setDescription('Sync blacklisted domains'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int { - $this->blacklistedDomainMapper->updateBlacklistedDomains(); - return 1; - } -} -- GitLab From 0d945457dbd64ba64f587ea17b10a2b1067c26cf Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:40:20 -0700 Subject: [PATCH 26/39] added command #13 --- appinfo/info.xml | 1 + lib/Command/SyncBlacklistedDomains.php | 37 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 lib/Command/SyncBlacklistedDomains.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 351006aa..6b417bf1 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -27,5 +27,6 @@ OCA\EcloudAccounts\Command\Migrate2FASecrets OCA\EcloudAccounts\Command\MigrateWebmailAddressbooks + OCA\EcloudAccounts\Command\SyncBlacklistedDomains diff --git a/lib/Command/SyncBlacklistedDomains.php b/lib/Command/SyncBlacklistedDomains.php new file mode 100644 index 00000000..18451ca5 --- /dev/null +++ b/lib/Command/SyncBlacklistedDomains.php @@ -0,0 +1,37 @@ +blacklistedDomainMapper = $blacklistedDomainMapper; + parent::__construct(); + } + + protected function configure(): void { + $this + ->setName('ecloud-accounts:migrate-blacklisted-domains') + ->setDescription('Migrates blacklisted domains') + ->addOption( + 'users', + null, + InputOption::VALUE_OPTIONAL, + 'comma separated list of users', + '' + ); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $this->blacklistedDomainMapper->updateBlacklistedDomains(); + } +} -- GitLab From 28006a974bc8c1a98a293a43fa1d5a1cb2e358e3 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:40:33 -0700 Subject: [PATCH 27/39] added command #13 --- lib/Command/SyncBlacklistedDomains.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Command/SyncBlacklistedDomains.php b/lib/Command/SyncBlacklistedDomains.php index 18451ca5..69877960 100644 --- a/lib/Command/SyncBlacklistedDomains.php +++ b/lib/Command/SyncBlacklistedDomains.php @@ -33,5 +33,6 @@ class SyncBlacklistedDomains extends Command { protected function execute(InputInterface $input, OutputInterface $output): int { $this->blacklistedDomainMapper->updateBlacklistedDomains(); + return 1; } } -- GitLab From b048194d62f5f6842348d2c20c466354b65c980c Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:46:17 -0700 Subject: [PATCH 28/39] added command #13 --- appinfo/info.xml | 2 +- ...SyncBlacklistedDomains.php => MigrateBlacklistedDomains.php} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename lib/Command/{SyncBlacklistedDomains.php => MigrateBlacklistedDomains.php} (95%) diff --git a/appinfo/info.xml b/appinfo/info.xml index 6b417bf1..aef24924 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -27,6 +27,6 @@ OCA\EcloudAccounts\Command\Migrate2FASecrets OCA\EcloudAccounts\Command\MigrateWebmailAddressbooks - OCA\EcloudAccounts\Command\SyncBlacklistedDomains + OCA\EcloudAccounts\Command\MigrateBlacklistedDomains diff --git a/lib/Command/SyncBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php similarity index 95% rename from lib/Command/SyncBlacklistedDomains.php rename to lib/Command/MigrateBlacklistedDomains.php index 69877960..29f7f076 100644 --- a/lib/Command/SyncBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class SyncBlacklistedDomains extends Command { +class MigrateBlacklistedDomains extends Command { private OutputInterface $commandOutput; private BlacklistedDomainMapper $blacklistedDomainMapper; -- GitLab From a0ff875efca23eb6402b95156c46251cc33b32cb Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 15 May 2024 23:57:50 -0700 Subject: [PATCH 29/39] changes in migration file --- appinfo/info.xml | 2 +- lib/Command/MigrateBlacklistedDomains.php | 25 ++++++++--------------- lib/Db/BlacklistedDomainMapper.php | 19 ----------------- lib/Service/UserService.php | 5 +++++ 4 files changed, 14 insertions(+), 37 deletions(-) delete mode 100644 lib/Db/BlacklistedDomainMapper.php diff --git a/appinfo/info.xml b/appinfo/info.xml index aef24924..9dd9e30a 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -25,8 +25,8 @@ OCA\EcloudAccounts\Settings\BetaSection + OCA\EcloudAccounts\Command\MigrateBlacklistedDomains OCA\EcloudAccounts\Command\Migrate2FASecrets OCA\EcloudAccounts\Command\MigrateWebmailAddressbooks - OCA\EcloudAccounts\Command\MigrateBlacklistedDomains diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index 29f7f076..dbcf6ce8 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -4,35 +4,26 @@ declare(strict_types=1); namespace OCA\EcloudAccounts\Command; -use OCA\EcloudAccounts\Db\BlacklistedDomainMapper; +use OCA\EcloudAccounts\Service\UserService; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class MigrateBlacklistedDomains extends Command { - private OutputInterface $commandOutput; - private BlacklistedDomainMapper $blacklistedDomainMapper; + private UserService $userService; - public function __construct(BlacklistedDomainMapper $blacklistedDomainMapper) { - $this->blacklistedDomainMapper = $blacklistedDomainMapper; + public function __construct(UserService $userService) { parent::__construct(); + $this->userService = $userService; } - protected function configure(): void { - $this - ->setName('ecloud-accounts:migrate-blacklisted-domains') - ->setDescription('Migrates blacklisted domains') - ->addOption( - 'users', - null, - InputOption::VALUE_OPTIONAL, - 'comma separated list of users', - '' - ); + protected function configure() { + $this->setName('ecloud-accounts:migrate-blacklisted-domains')->setDescription('Migrate blacklisted domains'); } protected function execute(InputInterface $input, OutputInterface $output): int { - $this->blacklistedDomainMapper->updateBlacklistedDomains(); + $this->userService->updateBlacklistedDomains(); + $output->writeln('Domains migrated successfully.'); return 1; } } diff --git a/lib/Db/BlacklistedDomainMapper.php b/lib/Db/BlacklistedDomainMapper.php deleted file mode 100644 index d7b9bf1c..00000000 --- a/lib/Db/BlacklistedDomainMapper.php +++ /dev/null @@ -1,19 +0,0 @@ -config = $config; - } - public function updateBlacklistedDomains() { - $blacklisted_domain_url = 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json'; - $json_data = file_get_contents($blacklisted_domain_url); - $this->config->setAppValue(Application::APP_ID, 'blacklisted_domains', $json_data); - } -} diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index 2d3d282b..86dfcc5c 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -544,4 +544,9 @@ class UserService { private function getDefaultQuota() { return $this->config->getSystemValueInt('default_quota_in_megabytes', 1024); } + public function updateBlacklistedDomains() { + $blacklisted_domain_url = 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json'; + $json_data = file_get_contents($blacklisted_domain_url); + $this->config->setAppValue(Application::APP_ID, 'blacklisted_domains', $json_data); + } } -- GitLab From 207f24ac8fbfd366deccbf26a485a7ed4285bd23 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 16 May 2024 00:24:46 -0700 Subject: [PATCH 30/39] added background job --- appinfo/info.xml | 3 + .../WeeklyBlacklistedDomainsJob.php | 55 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 9dd9e30a..c3b5d28e 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -29,4 +29,7 @@ OCA\EcloudAccounts\Command\Migrate2FASecrets OCA\EcloudAccounts\Command\MigrateWebmailAddressbooks + + OCA\EcloudAccounts\BackgroundJob\WeeklyBlacklistedDomainsJob + diff --git a/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php b/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php new file mode 100644 index 00000000..1a8a0f6a --- /dev/null +++ b/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php @@ -0,0 +1,55 @@ + + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OCA\EmailRecovery\BackgroundJob; + +use OCA\EcloudAccounts\Service\UserService; +use OCP\AppFramework\Utility\ITimeFactory; +use OCP\BackgroundJob\TimedJob; +use Psr\Log\LoggerInterface; + +class WeeklyBlacklistedDomainsJob extends TimedJob { + private LoggerInterface $logger; + private UserService $userService; + private ITimeFactory $timeFactory; + + + public function __construct(LoggerInterface $logger, ITimeFactory $timeFactory, UserService $userService) { + parent::__construct($timeFactory); + + $this->setInterval(7 * 24 * 60 * 60); // Run for 7 days + $this->timeFactory = $timeFactory; + $this->userService = $userService; + $this->logger = $logger; + } + + protected function run($argument): void { + try { + $this->userService->updateBlacklistedDomains(); + } catch (\Exception $e) { + $this->logger->error('Error running blacklisted domain migration', ['exception' => $e]); + return; + } + } +} -- GitLab From 453dd1601149688544450bfec79c1f2114f9063e Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 16 May 2024 00:25:43 -0700 Subject: [PATCH 31/39] added background job --- appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index c3b5d28e..2c1ba2ac 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -31,5 +31,5 @@ OCA\EcloudAccounts\BackgroundJob\WeeklyBlacklistedDomainsJob - + -- GitLab From a4e649ec5a2c7a754c18fb4d2473198914526653 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 16 May 2024 00:26:04 -0700 Subject: [PATCH 32/39] added background job --- lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php b/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php index 1a8a0f6a..c6e8b905 100644 --- a/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php +++ b/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php @@ -22,7 +22,7 @@ declare(strict_types=1); * */ -namespace OCA\EmailRecovery\BackgroundJob; +namespace OCA\EcloudAccounts\BackgroundJob; use OCA\EcloudAccounts\Service\UserService; use OCP\AppFramework\Utility\ITimeFactory; -- GitLab From e50dcf6d79142cb905a33c73be72f83213fcb048 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 16 May 2024 00:35:43 -0700 Subject: [PATCH 33/39] added background job --- .../WeeklyBlacklistedDomainsJob.php | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php b/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php index c6e8b905..a540441a 100644 --- a/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php +++ b/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php @@ -1,26 +1,6 @@ - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ namespace OCA\EcloudAccounts\BackgroundJob; -- GitLab From beed2fd10e35f972ff74083bf94d7f5aeff77f15 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 16 May 2024 11:50:12 -0700 Subject: [PATCH 34/39] Resolved feedbacks --- lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php | 7 +++---- lib/Command/MigrateBlacklistedDomains.php | 5 +++-- lib/Service/UserService.php | 14 ++++++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php b/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php index a540441a..20add743 100644 --- a/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php +++ b/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php @@ -13,12 +13,11 @@ class WeeklyBlacklistedDomainsJob extends TimedJob { private LoggerInterface $logger; private UserService $userService; private ITimeFactory $timeFactory; - - + public const INTERVAL_PERIOD = 7 * 24 * 60 * 60;// Run for 7 days public function __construct(LoggerInterface $logger, ITimeFactory $timeFactory, UserService $userService) { parent::__construct($timeFactory); - $this->setInterval(7 * 24 * 60 * 60); // Run for 7 days + $this->setInterval(self::INTERVAL_PERIOD); $this->timeFactory = $timeFactory; $this->userService = $userService; $this->logger = $logger; @@ -28,7 +27,7 @@ class WeeklyBlacklistedDomainsJob extends TimedJob { try { $this->userService->updateBlacklistedDomains(); } catch (\Exception $e) { - $this->logger->error('Error running blacklisted domain migration', ['exception' => $e]); + $this->logger->logException('Error updating blacklisted domains for account creation', ['exception' => $e]); return; } } diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/MigrateBlacklistedDomains.php index dbcf6ce8..13d9a2b3 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/MigrateBlacklistedDomains.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace OCA\EcloudAccounts\Command; +use OCA\EcloudAccounts\AppInfo\Application; use OCA\EcloudAccounts\Service\UserService; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -18,12 +19,12 @@ class MigrateBlacklistedDomains extends Command { } protected function configure() { - $this->setName('ecloud-accounts:migrate-blacklisted-domains')->setDescription('Migrate blacklisted domains'); + $this->setName(Application::APP_ID.':migrate-blacklisted-domains')->setDescription('Migrate blacklisted domains'); } protected function execute(InputInterface $input, OutputInterface $output): int { $this->userService->updateBlacklistedDomains(); - $output->writeln('Domains migrated successfully.'); + $output->writeln('Updated blacklisted domains for creation.'); return 1; } } diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index 86dfcc5c..c26fd380 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -285,12 +285,18 @@ class UserService { * @return bool True if the email domain is blacklisted, false otherwise. */ public function isBlacklistedEmail(string $email): bool { + // Get the blacklisted domains from configuration + $blacklistedDomainsInJson = $this->config->getAppValue(Application::APP_ID, 'blacklisted_domains'); + $blacklistedDomains = json_decode($blacklistedDomainsInJson, true); - $json_data = $this->config->getAppValue(Application::APP_ID, 'blacklisted_domains'); - $blacklisted_domains = json_decode($json_data, true); + // Split the email address into parts using explode + $emailParts = explode('@', $email); - $email_domain = strtolower(substr(strrchr($email, "@"), 1)); - if (in_array($email_domain, $blacklisted_domains)) { + // Extract the domain part + $emailDomain = strtolower(end($emailParts)); + + // Check if the email domain is in the blacklisted domains array + if (in_array($emailDomain, $blacklistedDomains)) { return true; // Email domain is blacklisted } return false; // Email domain is not blacklisted -- GitLab From ec723448b4933aeae8de85e7c5b82032ead5545d Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 16 May 2024 13:00:52 -0700 Subject: [PATCH 35/39] renamed file --- appinfo/info.xml | 2 +- ...eeklyBlacklistedDomainsJob.php => BlacklistedDomainsJob.php} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename lib/BackgroundJob/{WeeklyBlacklistedDomainsJob.php => BlacklistedDomainsJob.php} (94%) diff --git a/appinfo/info.xml b/appinfo/info.xml index 2c1ba2ac..11d3725d 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -30,6 +30,6 @@ OCA\EcloudAccounts\Command\MigrateWebmailAddressbooks - OCA\EcloudAccounts\BackgroundJob\WeeklyBlacklistedDomainsJob + OCA\EcloudAccounts\BackgroundJob\BlacklistedDomainsJob diff --git a/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php b/lib/BackgroundJob/BlacklistedDomainsJob.php similarity index 94% rename from lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php rename to lib/BackgroundJob/BlacklistedDomainsJob.php index 20add743..34f48a32 100644 --- a/lib/BackgroundJob/WeeklyBlacklistedDomainsJob.php +++ b/lib/BackgroundJob/BlacklistedDomainsJob.php @@ -9,7 +9,7 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\TimedJob; use Psr\Log\LoggerInterface; -class WeeklyBlacklistedDomainsJob extends TimedJob { +class BlacklistedDomainsJob extends TimedJob { private LoggerInterface $logger; private UserService $userService; private ITimeFactory $timeFactory; -- GitLab From 9b6c5180970bac8ed77a369bafd9b935acbda9fb Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 16 May 2024 13:52:23 -0700 Subject: [PATCH 36/39] set timesensitivity to false --- lib/BackgroundJob/BlacklistedDomainsJob.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/BackgroundJob/BlacklistedDomainsJob.php b/lib/BackgroundJob/BlacklistedDomainsJob.php index 34f48a32..cf776076 100644 --- a/lib/BackgroundJob/BlacklistedDomainsJob.php +++ b/lib/BackgroundJob/BlacklistedDomainsJob.php @@ -18,6 +18,7 @@ class BlacklistedDomainsJob extends TimedJob { parent::__construct($timeFactory); $this->setInterval(self::INTERVAL_PERIOD); + $this->setTimeSensitivity(self::TIME_INSENSITIVE); $this->timeFactory = $timeFactory; $this->userService = $userService; $this->logger = $logger; -- GitLab From 529194a2aed1ed8f572701260f0e8e045f881cfd Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 16 May 2024 14:12:11 -0700 Subject: [PATCH 37/39] Added changes --- appinfo/info.xml | 2 +- ...teBlacklistedDomains.php => UpdateBlacklistedDomains.php} | 4 ++-- lib/Service/UserService.php | 5 +---- 3 files changed, 4 insertions(+), 7 deletions(-) rename lib/Command/{MigrateBlacklistedDomains.php => UpdateBlacklistedDomains.php} (81%) diff --git a/appinfo/info.xml b/appinfo/info.xml index 11d3725d..96326e75 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -25,7 +25,7 @@ OCA\EcloudAccounts\Settings\BetaSection - OCA\EcloudAccounts\Command\MigrateBlacklistedDomains + OCA\EcloudAccounts\Command\UpdateBlacklistedDomains OCA\EcloudAccounts\Command\Migrate2FASecrets OCA\EcloudAccounts\Command\MigrateWebmailAddressbooks diff --git a/lib/Command/MigrateBlacklistedDomains.php b/lib/Command/UpdateBlacklistedDomains.php similarity index 81% rename from lib/Command/MigrateBlacklistedDomains.php rename to lib/Command/UpdateBlacklistedDomains.php index 13d9a2b3..8b51a28a 100644 --- a/lib/Command/MigrateBlacklistedDomains.php +++ b/lib/Command/UpdateBlacklistedDomains.php @@ -10,7 +10,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class MigrateBlacklistedDomains extends Command { +class UpdateBlacklistedDomains extends Command { private UserService $userService; public function __construct(UserService $userService) { @@ -19,7 +19,7 @@ class MigrateBlacklistedDomains extends Command { } protected function configure() { - $this->setName(Application::APP_ID.':migrate-blacklisted-domains')->setDescription('Migrate blacklisted domains'); + $this->setName(Application::APP_ID.':update-blacklisted-domains')->setDescription('Update blacklisted domains'); } protected function execute(InputInterface $input, OutputInterface $output): int { diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index c26fd380..cf01ccd2 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -296,10 +296,7 @@ class UserService { $emailDomain = strtolower(end($emailParts)); // Check if the email domain is in the blacklisted domains array - if (in_array($emailDomain, $blacklistedDomains)) { - return true; // Email domain is blacklisted - } - return false; // Email domain is not blacklisted + return in_array($emailDomain, $blacklistedDomains); } /** * Add a new user to the LDAP directory. -- GitLab From 6f50918b415048ca33e07b4ff64234ed4e2ec463 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 17 May 2024 18:46:22 -0700 Subject: [PATCH 38/39] added message change in fr, en --- l10n/de.js | 2 +- l10n/de.json | 2 +- l10n/en.js | 2 +- l10n/en.json | 2 +- l10n/es.js | 2 +- l10n/es.json | 2 +- l10n/fr.js | 2 +- l10n/fr.json | 2 +- l10n/it.js | 2 +- l10n/it.json | 2 +- lib/Service/UserService.php | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/l10n/de.js b/l10n/de.js index 893a1479..6dfab412 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -85,6 +85,6 @@ OC.L10N.register( "Captcha is not verified!": "Captcha wird nicht überprüft!", "A server-side error occurred while processing your request! Please try again later.": "Ein serverseitiger Fehler ist bei der Bearbeitung Ihrer Anfrage aufgetreten! Bitte versuchen Sie es später noch einmal.", "An error occurred while creating your account!": "Beim Anlegen Ihres Kontos ist ein Fehler aufgetreten!", - "The entered recovery email domain is blacklisted. Please try another.": "Die eingegebene Wiederherstellungs-E-Mail-Domäne steht auf der schwarzen Liste. Bitte versuchen Sie eine andere." + "The domain of this email address is blacklisted. Please provide another recovery address.": "Die eingegebene Wiederherstellungs-E-Mail-Domäne steht auf der schwarzen Liste. Bitte versuchen Sie eine andere." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/de.json b/l10n/de.json index b6509a5e..85030aad 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -83,7 +83,7 @@ "Captcha is not verified!": "Captcha wird nicht überprüft!", "A server-side error occurred while processing your request! Please try again later.": "Ein serverseitiger Fehler ist bei der Bearbeitung Ihrer Anfrage aufgetreten! Bitte versuchen Sie es später noch einmal.", "An error occurred while creating your account!": "Beim Anlegen Ihres Kontos ist ein Fehler aufgetreten!", - "The entered recovery email domain is blacklisted. Please try another.": "Die eingegebene Wiederherstellungs-E-Mail-Domäne steht auf der schwarzen Liste. Bitte versuchen Sie eine andere." + "The domain of this email address is blacklisted. Please provide another recovery address.": "Die eingegebene Wiederherstellungs-E-Mail-Domäne steht auf der schwarzen Liste. Bitte versuchen Sie eine andere." }, "pluralForm": "nplurals=2; plural=(n != 1);" } diff --git a/l10n/en.js b/l10n/en.js index dee2faae..b25bf722 100644 --- a/l10n/en.js +++ b/l10n/en.js @@ -89,6 +89,6 @@ OC.L10N.register( "Captcha is not verified!": "Captcha is not verified!", "A server-side error occurred while processing your request! Please try again later.": "A server-side error occurred while processing your request! Please try again later.", "An error occurred while creating your account!": "An error occurred while creating your account!", - "The entered recovery email domain is blacklisted. Please try another.": "The entered recovery email domain is blacklisted. Please try another." + "The domain of this email address is blacklisted. Please provide another recovery address.": "The domain of this email address is blacklisted. Please provide another recovery address." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/en.json b/l10n/en.json index df4c8dbc..be378a0a 100644 --- a/l10n/en.json +++ b/l10n/en.json @@ -85,7 +85,7 @@ "Captcha is not verified!": "Captcha is not verified!", "A server-side error occurred while processing your request! Please try again later.": "A server-side error occurred while processing your request! Please try again later.", "An error occurred while creating your account!": "An error occurred while creating your account!", - "The entered recovery email domain is blacklisted. Please try another.": "The entered recovery email domain is blacklisted. Please try another." + "The domain of this email address is blacklisted. Please provide another recovery address.": "The domain of this email address is blacklisted. Please provide another recovery address." }, "pluralForm": "nplurals=2; plural=(n != 1);" } diff --git a/l10n/es.js b/l10n/es.js index 2daeaf56..166d8d75 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -87,6 +87,6 @@ OC.L10N.register( "Captcha is not verified!": "¡Captcha no está verificado!", "A server-side error occurred while processing your request! Please try again later.": "Hubo un error en el servidor al procesar tu solicitud. Por favor, inténtalo más tarde.", "An error occurred while creating your account!": "¡Hubo un error creando tu cuenta!", - "The entered recovery email domain is blacklisted. Please try another.": "El dominio de correo electrónico de recuperación introducido está en la lista negra. Pruebe con otro." + "The domain of this email address is blacklisted. Please provide another recovery address.": "El dominio de correo electrónico de recuperación introducido está en la lista negra. Pruebe con otro." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/es.json b/l10n/es.json index a39ebc91..fef06d95 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -86,7 +86,7 @@ "Captcha is not verified!": "¡Captcha no está verificado!", "A server-side error occurred while processing your request! Please try again later.": "Hubo un error en el servidor al procesar tu solicitud. Por favor, inténtalo más tarde.", "An error occurred while creating your account!": "¡Hubo un error creando tu cuenta!", - "The entered recovery email domain is blacklisted. Please try another.": "El dominio de correo electrónico de recuperación introducido está en la lista negra. Pruebe con otro." + "The domain of this email address is blacklisted. Please provide another recovery address.": "El dominio de correo electrónico de recuperación introducido está en la lista negra. Pruebe con otro." }, "pluralForm": "nplurals=2; plural=(n != 1);" } diff --git a/l10n/fr.js b/l10n/fr.js index dfe24638..6efaeeca 100644 --- a/l10n/fr.js +++ b/l10n/fr.js @@ -86,6 +86,6 @@ OC.L10N.register( "Captcha is not verified!": "Captcha n'est pas vérifié !", "A server-side error occurred while processing your request! Please try again later.": "Erreur du serveur dans la gestion de votre demande ! Merci d'essayer ultérieurement.", "An error occurred while creating your account!": "Une erreur s'est produite lors de la création de votre compte!", - "The entered recovery email domain is blacklisted. Please try another.": "Le domaine de l'email de récupération saisi est sur liste noire. Veuillez en essayer un autre." + "The domain of this email address is blacklisted. Please provide another recovery address.": "Le domain de cette adresse e-mail est sur liste noire. Merci de bien vouloir fournir une autre adresse de récupération." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/fr.json b/l10n/fr.json index 5e64e303..19facc30 100644 --- a/l10n/fr.json +++ b/l10n/fr.json @@ -85,7 +85,7 @@ "Captcha is not verified!": "Captcha n'est pas vérifié !", "A server-side error occurred while processing your request! Please try again later.": "Erreur du serveur dans la gestion de votre demande ! Merci d'essayer ultérieurement.", "An error occurred while creating your account!": "Une erreur s'est produite lors de la création de votre compte!", - "The entered recovery email domain is blacklisted. Please try another.": "Le domaine de l'email de récupération saisi est sur liste noire. Veuillez en essayer un autre." + "The domain of this email address is blacklisted. Please provide another recovery address.": "Le domain de cette adresse e-mail est sur liste noire. Merci de bien vouloir fournir une autre adresse de récupération." }, "pluralForm": "nplurals=2; plural=(n != 1);" } diff --git a/l10n/it.js b/l10n/it.js index e16ae713..e6e4d019 100644 --- a/l10n/it.js +++ b/l10n/it.js @@ -86,6 +86,6 @@ OC.L10N.register( "Captcha is not verified!": "Il Captcha non è verificato!", "A server-side error occurred while processing your request! Please try again later.": "Si è verificato un errore lato server nel processare la tua richiesta! Ritenta più tardi.", "An error occurred while creating your account!": "Si è verificato un errore nella creazione dell'account!", - "The entered recovery email domain is blacklisted. Please try another.": "Il dominio e-mail di recupero inserito è nella lista nera. Provare con un altro." + "The domain of this email address is blacklisted. Please provide another recovery address.": "Il dominio e-mail di recupero inserito è nella lista nera. Provare con un altro." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/it.json b/l10n/it.json index a2a9675b..f72e554d 100644 --- a/l10n/it.json +++ b/l10n/it.json @@ -81,7 +81,7 @@ "Captcha is not verified!": "Il Captcha non è verificato!", "A server-side error occurred while processing your request! Please try again later.": "Si è verificato un errore lato server nel processare la tua richiesta! Ritenta più tardi.", "An error occurred while creating your account!": "Si è verificato un errore nella creazione dell'account!", - "The entered recovery email domain is blacklisted. Please try another.": "Il dominio e-mail di recupero inserito è nella lista nera. Provare con un altro." + "The domain of this email address is blacklisted. Please provide another recovery address.": "Il dominio e-mail di recupero inserito è nella lista nera. Provare con un altro." }, "pluralForm": "nplurals=2; plural=(n != 1);" } diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php index cf01ccd2..c8ad16b8 100644 --- a/lib/Service/UserService.php +++ b/lib/Service/UserService.php @@ -275,7 +275,7 @@ class UserService { throw new Exception('You cannot set an email address with a Murena domain as recovery email address.'); } if ($this->isBlacklistedEmail($recoveryEmail)) { - throw new BlacklistedEmailException('The entered recovery email domain is blacklisted. Please try another.'); + throw new BlacklistedEmailException('The domain of this email address is blacklisted. Please provide another recovery address.'); } } /** -- GitLab From 4bf83db18c37cb36e803fbb98976e3eb4421bcad Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Mon, 20 May 2024 10:12:12 -0700 Subject: [PATCH 39/39] changes in translations --- l10n/de.js | 2 +- l10n/de.json | 2 +- l10n/es.js | 2 +- l10n/es.json | 2 +- l10n/it.js | 2 +- l10n/it.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/l10n/de.js b/l10n/de.js index 6dfab412..26bd31c0 100644 --- a/l10n/de.js +++ b/l10n/de.js @@ -85,6 +85,6 @@ OC.L10N.register( "Captcha is not verified!": "Captcha wird nicht überprüft!", "A server-side error occurred while processing your request! Please try again later.": "Ein serverseitiger Fehler ist bei der Bearbeitung Ihrer Anfrage aufgetreten! Bitte versuchen Sie es später noch einmal.", "An error occurred while creating your account!": "Beim Anlegen Ihres Kontos ist ein Fehler aufgetreten!", - "The domain of this email address is blacklisted. Please provide another recovery address.": "Die eingegebene Wiederherstellungs-E-Mail-Domäne steht auf der schwarzen Liste. Bitte versuchen Sie eine andere." + "The domain of this email address is blacklisted. Please provide another recovery address.": "Die Domäne dieser E-Mailadresse ist auf der Sperrliste. Bitte geben Sie eine andere E-Mailadresse an." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/de.json b/l10n/de.json index 85030aad..581f0a74 100644 --- a/l10n/de.json +++ b/l10n/de.json @@ -83,7 +83,7 @@ "Captcha is not verified!": "Captcha wird nicht überprüft!", "A server-side error occurred while processing your request! Please try again later.": "Ein serverseitiger Fehler ist bei der Bearbeitung Ihrer Anfrage aufgetreten! Bitte versuchen Sie es später noch einmal.", "An error occurred while creating your account!": "Beim Anlegen Ihres Kontos ist ein Fehler aufgetreten!", - "The domain of this email address is blacklisted. Please provide another recovery address.": "Die eingegebene Wiederherstellungs-E-Mail-Domäne steht auf der schwarzen Liste. Bitte versuchen Sie eine andere." + "The domain of this email address is blacklisted. Please provide another recovery address.": "Die Domäne dieser E-Mailadresse ist auf der Sperrliste. Bitte geben Sie eine andere E-Mailadresse an." }, "pluralForm": "nplurals=2; plural=(n != 1);" } diff --git a/l10n/es.js b/l10n/es.js index 166d8d75..19fa33c7 100644 --- a/l10n/es.js +++ b/l10n/es.js @@ -87,6 +87,6 @@ OC.L10N.register( "Captcha is not verified!": "¡Captcha no está verificado!", "A server-side error occurred while processing your request! Please try again later.": "Hubo un error en el servidor al procesar tu solicitud. Por favor, inténtalo más tarde.", "An error occurred while creating your account!": "¡Hubo un error creando tu cuenta!", - "The domain of this email address is blacklisted. Please provide another recovery address.": "El dominio de correo electrónico de recuperación introducido está en la lista negra. Pruebe con otro." + "The domain of this email address is blacklisted. Please provide another recovery address.": "El dominio de esta dirección de correo electrónico está en lista negra. Por favor, proporciona otra dirección de recuperación." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/es.json b/l10n/es.json index fef06d95..867f150d 100644 --- a/l10n/es.json +++ b/l10n/es.json @@ -86,7 +86,7 @@ "Captcha is not verified!": "¡Captcha no está verificado!", "A server-side error occurred while processing your request! Please try again later.": "Hubo un error en el servidor al procesar tu solicitud. Por favor, inténtalo más tarde.", "An error occurred while creating your account!": "¡Hubo un error creando tu cuenta!", - "The domain of this email address is blacklisted. Please provide another recovery address.": "El dominio de correo electrónico de recuperación introducido está en la lista negra. Pruebe con otro." + "The domain of this email address is blacklisted. Please provide another recovery address.": "El dominio de esta dirección de correo electrónico está en lista negra. Por favor, proporciona otra dirección de recuperación." }, "pluralForm": "nplurals=2; plural=(n != 1);" } diff --git a/l10n/it.js b/l10n/it.js index e6e4d019..84c211cd 100644 --- a/l10n/it.js +++ b/l10n/it.js @@ -86,6 +86,6 @@ OC.L10N.register( "Captcha is not verified!": "Il Captcha non è verificato!", "A server-side error occurred while processing your request! Please try again later.": "Si è verificato un errore lato server nel processare la tua richiesta! Ritenta più tardi.", "An error occurred while creating your account!": "Si è verificato un errore nella creazione dell'account!", - "The domain of this email address is blacklisted. Please provide another recovery address.": "Il dominio e-mail di recupero inserito è nella lista nera. Provare con un altro." + "The domain of this email address is blacklisted. Please provide another recovery address.": "Il dominio cui appartiene questo indirizzo e-mail è contenuto in una black list. Inserisci un indirizzo di recovery differente." }, "nplurals=2; plural=(n != 1);"); diff --git a/l10n/it.json b/l10n/it.json index f72e554d..2685c394 100644 --- a/l10n/it.json +++ b/l10n/it.json @@ -81,7 +81,7 @@ "Captcha is not verified!": "Il Captcha non è verificato!", "A server-side error occurred while processing your request! Please try again later.": "Si è verificato un errore lato server nel processare la tua richiesta! Ritenta più tardi.", "An error occurred while creating your account!": "Si è verificato un errore nella creazione dell'account!", - "The domain of this email address is blacklisted. Please provide another recovery address.": "Il dominio e-mail di recupero inserito è nella lista nera. Provare con un altro." + "The domain of this email address is blacklisted. Please provide another recovery address.": "Il dominio cui appartiene questo indirizzo e-mail è contenuto in una black list. Inserisci un indirizzo di recovery differente." }, "pluralForm": "nplurals=2; plural=(n != 1);" } -- GitLab