diff --git a/composer.json b/composer.json index 3fd73e5d3..1131a4080 100644 --- a/composer.json +++ b/composer.json @@ -85,6 +85,7 @@ "unocha/gtm_barebones": "^1.1", "unocha/ocha_ai": "^1.7", "unocha/ocha_content_classification": "^1.0", + "unocha/ocha_entraid": "^1.0", "unocha/ocha_monitoring": "^1.0", "webflo/drupal-finder": "^1.2.2" }, diff --git a/composer.lock b/composer.lock index d85ad3b6d..45b447dad 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b8b3d79cb86b6b8956b17662a2b2dba7", + "content-hash": "44aba325c78bc76813d54e96d5698924", "packages": [ { "name": "asm89/stack-cors", @@ -17722,6 +17722,49 @@ }, "time": "2024-11-15T07:26:19+00:00" }, + { + "name": "unocha/ocha_entraid", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/UN-OCHA/ocha_entraid.git", + "reference": "bc788a50b42971f4dbbfb101c619cf033cdceb4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/UN-OCHA/ocha_entraid/zipball/bc788a50b42971f4dbbfb101c619cf033cdceb4d", + "reference": "bc788a50b42971f4dbbfb101c619cf033cdceb4d", + "shasum": "" + }, + "require": { + "drupal/core": "^10", + "drupal/honeypot": "^2", + "drupal/openid_connect": "dev-3.x", + "drupal/openid_connect_windows_aad": "^2.0@beta", + "php": ">=8.3" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "drupal/coder": "^8.3", + "phpcompatibility/php-compatibility": "^9.3" + }, + "type": "drupal-module", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "UNOCHA" + } + ], + "description": "OCHA Entra ID module", + "support": { + "issues": "https://github.com/UN-OCHA/ocha_entraid/issues", + "source": "https://github.com/UN-OCHA/ocha_entraid/tree/v1.0.0" + }, + "time": "2024-11-12T06:36:39+00:00" + }, { "name": "unocha/ocha_monitoring", "version": "1.0.18", diff --git a/config/core.extension.yml b/config/core.extension.yml index d7db6a7ba..2489fe5c5 100644 --- a/config/core.extension.yml +++ b/config/core.extension.yml @@ -61,6 +61,7 @@ module: ocha_ai: 0 ocha_ai_chat: 0 ocha_ai_tag: 0 + ocha_entraid: 0 ocha_content_classification: 0 ocha_monitoring: 0 openid_connect: 0 @@ -77,7 +78,6 @@ module: reliefweb_disaster_map: 0 reliefweb_dsr: 0 reliefweb_entities: 0 - reliefweb_entraid: 0 reliefweb_fields: 0 reliefweb_files: 0 reliefweb_form: 0 diff --git a/config/ocha_entraid.settings.yml b/config/ocha_entraid.settings.yml new file mode 100644 index 000000000..f4ab34550 --- /dev/null +++ b/config/ocha_entraid.settings.yml @@ -0,0 +1,30 @@ +_core: + default_config_hash: NAmQvdKWBfPlHEZzOU3fgGjxcYBQTfz7xn9goDv0r80 +uimc_api: + token_url: '' + registration_url: '' + user_details_url: '' + group_management_url: '' + username: '' + password: '' + consumer_key: '' + consumer_secret: '' + send_email: false + verify_ssl: true + request_timeout: 10 + default_group: '' + encryption_key: '' +messages: + invalid_email: 'Invalid valid email address.' + login_explanation: '

Please enter your email address to access your account.

' + login_account_blocked: 'We encountered an issue with your account. Please reach out for assistance.' + login_account_not_found: 'We were unable to find your account. Please check your information and try again.' + login_account_verification_error: 'We encountered an issue while verifying your account. Please try again later or reach out for assistance if the problem persists.' + login_redirection_error: 'We are experiencing difficulties with the login process. Please try again later or reach out for assistance if the issue continues.' + registration_explanation: '

Create an account to easily access our services.
If you already possess a UN email address, please log in here directly.

' + registration_invalid_first_name: 'First name must contain only letters, spaces, hyphens, or apostrophes and be no longer than 30 characters.' + registration_invalid_last_name: 'Last name must contain only letters, spaces, hyphens, or apostrophes and be no longer than 30 characters.' + registration_invalid_email: 'Email must contain only letters, numbers, hyphens, or periods and be no longer than 100 characters.' + registration_success: 'Thank you for signing up. Please wait a moment and then log in to finalize your registration.' + registration_success_with_email: 'Thank you for signing up! A confirmation email has been sent to your mailbox. Please check your email and follow the instructions to finalize your registration.' + registration_failure: 'We encountered an issue while processing your registration. Please try again later or reach out for assistance.' diff --git a/html/modules/custom/reliefweb_entraid/README.md b/html/modules/custom/reliefweb_entraid/README.md index 80749267f..606980f96 100644 --- a/html/modules/custom/reliefweb_entraid/README.md +++ b/html/modules/custom/reliefweb_entraid/README.md @@ -3,4 +3,4 @@ Reliefweb Entra ID This module provides user authentication tweaks for Entra ID -* Provide a `/user/login/entraid` callback to redirect to the Entra ID login workflow. +* Provide a `/user/login/reliefweb-entraid-direct` callback to redirect to the Entra ID login workflow. diff --git a/html/modules/custom/reliefweb_entraid/reliefweb_entraid.routing.yml b/html/modules/custom/reliefweb_entraid/reliefweb_entraid.routing.yml index 93872e877..3d624198d 100644 --- a/html/modules/custom/reliefweb_entraid/reliefweb_entraid.routing.yml +++ b/html/modules/custom/reliefweb_entraid/reliefweb_entraid.routing.yml @@ -1,5 +1,5 @@ reliefweb_entraid.login: - path: '/user/login/entraid' + path: '/user/login/reliefweb-entraid-direct' defaults: _controller: '\Drupal\reliefweb_entraid\Controller\AuthController::redirectLogin' _title: 'Login with Unite ID' diff --git a/html/modules/custom/reliefweb_entraid/tests/src/ExistingSite/ReliefwebEntraidLoginTest.php b/html/modules/custom/reliefweb_entraid/tests/src/ExistingSite/ReliefwebEntraidLoginTest.php index 4ba5e1e9c..3100b3609 100644 --- a/html/modules/custom/reliefweb_entraid/tests/src/ExistingSite/ReliefwebEntraidLoginTest.php +++ b/html/modules/custom/reliefweb_entraid/tests/src/ExistingSite/ReliefwebEntraidLoginTest.php @@ -49,6 +49,12 @@ protected function tearDown(): void { * @covers ::redirectLogin() */ public function testRedirectLogin() { + // Skip if the module is not installed. + if (!$this->container->get('module_handler')->moduleExists('reliefweb_entraid')) { + $this->assertTrue(TRUE); + return; + } + // Get the EntraID configuration. $entraid_config = $this->container ->get('config.factory') @@ -63,7 +69,7 @@ public function testRedirectLogin() { // The incomplete config will results in an exception and 404 response // will be returned. - $this->drupalGet('/user/login/entraid'); + $this->drupalGet('/user/login/reliefweb-entraid-direct'); $this->assertSession()->statusCodeEquals(404); // Set the endpoints. We just point at the robots.txt as we know it exists @@ -75,7 +81,7 @@ public function testRedirectLogin() { $entraid_config->setData($data)->save(); // If the redirection works, a 200 will be returned. - $this->drupalGet('/user/login/entraid'); + $this->drupalGet('/user/login/reliefweb-entraid-direct'); $this->assertSession()->statusCodeEquals(200); $this->assertStringContainsString('Disallow:', $this->getSession()->getPage()->getContent()); }