From ec4b9b088c875f967fdc160a21481361a101127b Mon Sep 17 00:00:00 2001 From: FreddleSpl0it Date: Fri, 29 Nov 2024 18:59:07 +0100 Subject: [PATCH] [Web] support multiple ldap hosts separated by comma --- data/web/inc/functions.inc.php | 5 +- data/web/lang/lang.en-gb.json | 1 + .../admin/tab-config-identity-provider.twig | 153 +++++++++++++----- 3 files changed, 116 insertions(+), 43 deletions(-) diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php index c7cab469d..6ae49e7bc 100644 --- a/data/web/inc/functions.inc.php +++ b/data/web/inc/functions.inc.php @@ -2240,6 +2240,7 @@ function identity_provider($_action = null, $_data = null, $_extra = null) { $required_settings = array('authsource', 'authorize_url', 'token_url', 'client_id', 'client_secret', 'redirect_url', 'userinfo_url', 'client_scopes'); break; case "ldap": + $_data['host'] = (!empty($_data['host'])) ? str_replace(" ", "", $_data['host']) : ""; $_data['port'] = (!empty($_data['port'])) ? intval($_data['port']) : 389; $_data['username_field'] = (!empty($_data['username_field'])) ? strtolower($_data['username_field']) : "mail"; $_data['attribute_field'] = (!empty($_data['attribute_field'])) ? strtolower($_data['attribute_field']) : ""; @@ -2356,7 +2357,7 @@ function identity_provider($_action = null, $_data = null, $_extra = null) { $options[LDAP_OPT_X_TLS_REQUIRE_CERT] = LDAP_OPT_X_TLS_NEVER; } $provider = new \LdapRecord\Connection([ - 'hosts' => [$_data['host']], + 'hosts' => explode(",", $_data['host']), 'port' => $_data['port'], 'base_dn' => $_data['basedn'], 'username' => $_data['binddn'], @@ -2450,7 +2451,7 @@ function identity_provider($_action = null, $_data = null, $_extra = null) { $options[LDAP_OPT_X_TLS_REQUIRE_CERT] = LDAP_OPT_X_TLS_NEVER; } $provider = new \LdapRecord\Connection([ - 'hosts' => [$settings['host']], + 'hosts' => explode(",", $settings['host']), 'port' => $settings['port'], 'base_dn' => $settings['basedn'], 'username' => $settings['binddn'], diff --git a/data/web/lang/lang.en-gb.json b/data/web/lang/lang.en-gb.json index 5c9c1b21b..c9a7f9dfa 100644 --- a/data/web/lang/lang.en-gb.json +++ b/data/web/lang/lang.en-gb.json @@ -225,6 +225,7 @@ "iam_description": "Configure an external Provider for Authentication
User's mailboxes will be automatically created upon their first login, provided that an attribute mapping has been set.", "iam_extra_permission": "For the following settings to work, the mailcow client in Keycloak needs a Service account and the permission to view-users.", "iam_host": "Host", + "iam_host_info": "Enter one or more LDAP hosts, separated by commas.", "iam_import_users": "Import Users", "iam_mapping": "Attribute Mapping", "iam_bindpass": "Bind Password", diff --git a/data/web/templates/admin/tab-config-identity-provider.twig b/data/web/templates/admin/tab-config-identity-provider.twig index e5103d970..e2cc56838 100644 --- a/data/web/templates/admin/tab-config-identity-provider.twig +++ b/data/web/templates/admin/tab-config-identity-provider.twig @@ -9,7 +9,9 @@

{{ lang.admin.iam_description|raw }}

- +
+ +
- +
+ +
- +
+ +
- +
+ +
- +
+ +
@@ -53,19 +63,25 @@
- +
+ +
- +
+ +
- +
+ +
Attribute @@ -121,13 +137,15 @@ {% endif %}
- +
{{ lang.admin.iam_extra_permission|raw }}
- +
+ +
@@ -140,7 +158,9 @@
- +
+ +
@@ -148,7 +168,9 @@
- +
+ +
@@ -156,14 +178,16 @@
- +
+ +
-
+
@@ -176,31 +200,41 @@
- +
+ +
- +
+ +
- +
+ +
- +
+ +
- +
+ +
@@ -209,19 +243,25 @@
- +
+ +
- +
+ +
- +
+ +
Attribute @@ -278,7 +318,7 @@
-
+
@@ -291,19 +331,26 @@
- -
- +
+ + +
+
+
- +
+ +
- +
+ +
@@ -311,7 +358,9 @@
- +
+ +
@@ -319,7 +368,9 @@
- +
+ +
@@ -327,37 +378,49 @@
- +
+ +
- +
+ +
- +
+ +
- +
+ +
- +
+ +
- +
+ +
@@ -366,7 +429,9 @@
- +
+ +
Attribute @@ -422,7 +487,9 @@ {% endif %}
- +
+ +
@@ -430,7 +497,9 @@
- +
+ +
@@ -438,14 +507,16 @@
- +
+ +
-
+