From 48b6fb825be824124213450c94e059a3849a507d Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 18 Sep 2024 15:43:25 +0200 Subject: [PATCH] WIP5 Signed-off-by: Louis Chemineau --- .../lib/Controller/ConfigAPIController.php | 1 - .../components/SettingsTabs/AdvancedTab.vue | 42 +++++-- .../src/components/SettingsTabs/ExpertTab.vue | 4 +- .../src/components/SettingsTabs/LoginTab.vue | 4 +- .../src/components/SettingsTabs/ServerTab.vue | 43 ++++--- .../src/services/ldapConfigService.ts | 106 ++++++++++++++++-- apps/user_ldap/src/services/wizardUtils.ts | 10 -- apps/user_ldap/src/store/config.ts | 102 ++++++++--------- apps/user_ldap/src/views/Settings.vue | 7 +- 9 files changed, 216 insertions(+), 103 deletions(-) delete mode 100644 apps/user_ldap/src/services/wizardUtils.ts diff --git a/apps/user_ldap/lib/Controller/ConfigAPIController.php b/apps/user_ldap/lib/Controller/ConfigAPIController.php index 8ce2486c153..2459cc016ed 100644 --- a/apps/user_ldap/lib/Controller/ConfigAPIController.php +++ b/apps/user_ldap/lib/Controller/ConfigAPIController.php @@ -12,7 +12,6 @@ use OCA\User_LDAP\Configuration; use OCA\User_LDAP\ConnectionFactory; use OCA\User_LDAP\Helper; use OCA\User_LDAP\Settings\Admin; -use OCP\AppFramework\Http; use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSBadRequestException; diff --git a/apps/user_ldap/src/components/SettingsTabs/AdvancedTab.vue b/apps/user_ldap/src/components/SettingsTabs/AdvancedTab.vue index dfb9ec4dfe4..4a984c44d8d 100644 --- a/apps/user_ldap/src/components/SettingsTabs/AdvancedTab.vue +++ b/apps/user_ldap/src/components/SettingsTabs/AdvancedTab.vue @@ -4,8 +4,8 @@ --> @@ -249,6 +249,24 @@ const instanceName = 'TODO' display: flex; flex-direction: column; gap: 8px; + + summary { + + h3 { + margin: 0; + display: inline; + cursor: pointer; + color: var(--color-text-lighter); + font-size: 16px; + + } + } + + &:hover, &[open] { + h3 { + color: var(--color-text-light); + } + } } } diff --git a/apps/user_ldap/src/components/SettingsTabs/ExpertTab.vue b/apps/user_ldap/src/components/SettingsTabs/ExpertTab.vue index bc407f00b5f..60d04ac332a 100644 --- a/apps/user_ldap/src/components/SettingsTabs/ExpertTab.vue +++ b/apps/user_ldap/src/components/SettingsTabs/ExpertTab.vue @@ -29,10 +29,10 @@
{{ t('user_ldap', 'Username-LDAP User Mapping') }} {{ t('user_ldap', 'Usernames are used to store and assign metadata. In order to precisely identify and recognize users, each LDAP user will have an internal username. This requires a mapping from username to LDAP user. The created username is mapped to the UUID of the LDAP user. Additionally the DN is cached as well to reduce LDAP interaction, but it is not used for identification. If the DN changes, the changes will be found. The internal username is used all over. Clearing the mappings will have leftovers everywhere. Clearing the mappings is not configuration sensitive, it affects all LDAP configurations! Never clear the mappings in a production environment, only in a testing or experimental stage.') }} - + {{ t('user_ldap', 'Clear Username-LDAP User Mapping') }} - + {{ t('user_ldap', 'Clear Groupname-LDAP Group Mapping') }}
diff --git a/apps/user_ldap/src/components/SettingsTabs/LoginTab.vue b/apps/user_ldap/src/components/SettingsTabs/LoginTab.vue index ed6de013b73..2ec27a969bd 100644 --- a/apps/user_ldap/src/components/SettingsTabs/LoginTab.vue +++ b/apps/user_ldap/src/components/SettingsTabs/LoginTab.vue @@ -7,9 +7,9 @@ {{ t('user_ldap', 'When logging in, {instanceName} will find the user based on the following attributes:', { instanceName }) }} @@ -60,17 +60,18 @@ :placeholder="t('user_ldap', 'One Base DN per line')" :helper-text="t('user_ldap', 'You can specify Base DN for users and groups in the Advanced tab')" /> - + {{ t('user_ldap', 'Detect Base DN') }} - + {{ t('user_ldap', 'Test Base DN') }}
- + {{ t('user_ldap', 'Manually enter LDAP filters (recommended for large directories)') }}
@@ -87,8 +88,7 @@ import { t } from '@nextcloud/l10n' import { NcButton, NcTextField, NcTextArea, NcCheckboxRadioSwitch } from '@nextcloud/vue' import { useLDAPConfigStore } from '../../store/config' - -const ldapConfigStore = useLDAPConfigStore() +import { callWizard } from '../../services/ldapConfigService' const { ldapConfigId } = defineProps({ ldapConfigId: { @@ -97,31 +97,42 @@ const { ldapConfigId } = defineProps({ }, }) -const ldapConfig = computed(() => ldapConfigStore.ldapConfigs[ldapConfigId]) +const ldapConfigStore = useLDAPConfigStore() -// TODO: use this -const advancedAdmin = ref(false) +const ldapConfig = computed(() => ldapConfigStore.ldapConfigs[ldapConfigId]) +const usersCount = ref(undefined) +const currentWizardActions = ref([]) /** * */ -async function detectPort() { - // TODO +async function guessPortAndTLS() { + currentWizardActions.value.push('guessPortAndTLS') + const { changes: { ldap_port: ldapPort } } = await callWizard('guessPortAndTLS', ldapConfigId) + ldapConfig.value.ldapPort = ldapPort + currentWizardActions.value.splice(currentWizardActions.value.indexOf('guessPortAndTLS'), 1) } /** * */ -async function detectBaseDN() { - // TODO +async function guessBaseDN() { + currentWizardActions.value.push('guessBaseDN') + const { changes: { ldap_base: ldapBase } } = await callWizard('guessBaseDN', ldapConfigId) + ldapConfig.value.ldapBase = ldapBase + currentWizardActions.value.splice(currentWizardActions.value.indexOf('guessPortAndTLS'), 1) } /** * */ -async function testBaseDN() { - // TODO +async function countInBaseDN() { + currentWizardActions.value.push('countInBaseDN') + const { changes: { ldap_test_base: ldapTestBase } } = await callWizard('countInBaseDN', ldapConfigId) + usersCount.value = ldapTestBase + currentWizardActions.value.splice(currentWizardActions.value.indexOf('guessPortAndTLS'), 1) } +