diff --git a/packages/frontend/@n8n/rest-api-client/src/api/index.ts b/packages/frontend/@n8n/rest-api-client/src/api/index.ts index 17b55a35cca..d01161effad 100644 --- a/packages/frontend/@n8n/rest-api-client/src/api/index.ts +++ b/packages/frontend/@n8n/rest-api-client/src/api/index.ts @@ -3,6 +3,7 @@ export * from './communityNodes'; export * from './ctas'; export * from './eventbus.ee'; export * from './events'; +export * from './ldap'; export * from './mfa'; export * from './nodeTypes'; export * from './npsSurvey'; diff --git a/packages/frontend/@n8n/rest-api-client/src/api/ldap.ts b/packages/frontend/@n8n/rest-api-client/src/api/ldap.ts new file mode 100644 index 00000000000..187c84cdebd --- /dev/null +++ b/packages/frontend/@n8n/rest-api-client/src/api/ldap.ts @@ -0,0 +1,77 @@ +import type { IRestApiContext } from '../types'; +import { makeRestApiRequest } from '../utils'; +import type { IDataObject } from 'n8n-workflow'; + +export interface LdapSyncData { + id: number; + startedAt: string; + endedAt: string; + created: number; + updated: number; + disabled: number; + scanned: number; + status: string; + error: string; + runMode: string; +} + +export interface LdapSyncTable { + status: string; + endedAt: string; + runTime: string; + runMode: string; + details: string; +} + +export interface LdapConfig { + loginEnabled: boolean; + loginLabel: string; + connectionUrl: string; + allowUnauthorizedCerts: boolean; + connectionSecurity: string; + connectionPort: number; + baseDn: string; + bindingAdminDn: string; + bindingAdminPassword: string; + firstNameAttribute: string; + lastNameAttribute: string; + emailAttribute: string; + loginIdAttribute: string; + ldapIdAttribute: string; + userFilter: string; + synchronizationEnabled: boolean; + synchronizationInterval: number; // minutes + searchPageSize: number; + searchTimeout: number; +} + +export async function getLdapConfig(context: IRestApiContext): Promise { + return await makeRestApiRequest(context, 'GET', '/ldap/config'); +} + +export async function testLdapConnection(context: IRestApiContext): Promise<{}> { + return await makeRestApiRequest(context, 'POST', '/ldap/test-connection'); +} + +export async function updateLdapConfig( + context: IRestApiContext, + adConfig: LdapConfig, +): Promise { + return await makeRestApiRequest( + context, + 'PUT', + '/ldap/config', + adConfig as unknown as IDataObject, + ); +} + +export async function runLdapSync(context: IRestApiContext, data: IDataObject): Promise<{}> { + return await makeRestApiRequest(context, 'POST', '/ldap/sync', data as unknown as IDataObject); +} + +export async function getLdapSynchronizations( + context: IRestApiContext, + pagination: { page: number }, +): Promise { + return await makeRestApiRequest(context, 'GET', '/ldap/sync', pagination); +} diff --git a/packages/frontend/editor-ui/src/Interface.ts b/packages/frontend/editor-ui/src/Interface.ts index dd2629d2b80..accb818cd83 100644 --- a/packages/frontend/editor-ui/src/Interface.ts +++ b/packages/frontend/editor-ui/src/Interface.ts @@ -1232,49 +1232,6 @@ export type SchemaType = | 'null' | 'undefined'; -export interface ILdapSyncData { - id: number; - startedAt: string; - endedAt: string; - created: number; - updated: number; - disabled: number; - scanned: number; - status: string; - error: string; - runMode: string; -} - -export interface ILdapSyncTable { - status: string; - endedAt: string; - runTime: string; - runMode: string; - details: string; -} - -export interface ILdapConfig { - loginEnabled: boolean; - loginLabel: string; - connectionUrl: string; - allowUnauthorizedCerts: boolean; - connectionSecurity: string; - connectionPort: number; - baseDn: string; - bindingAdminDn: string; - bindingAdminPassword: string; - firstNameAttribute: string; - lastNameAttribute: string; - emailAttribute: string; - loginIdAttribute: string; - ldapIdAttribute: string; - userFilter: string; - synchronizationEnabled: boolean; - synchronizationInterval: number; // minutes - searchPageSize: number; - searchTimeout: number; -} - export type Schema = { type: SchemaType; key?: string; value: string | Schema[]; path: string }; export type UsageState = { diff --git a/packages/frontend/editor-ui/src/api/ldap.ts b/packages/frontend/editor-ui/src/api/ldap.ts deleted file mode 100644 index 2665d257d77..00000000000 --- a/packages/frontend/editor-ui/src/api/ldap.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { ILdapConfig, ILdapSyncData } from '@/Interface'; -import type { IRestApiContext } from '@n8n/rest-api-client'; -import { makeRestApiRequest } from '@n8n/rest-api-client'; -import type { IDataObject } from 'n8n-workflow'; - -export async function getLdapConfig(context: IRestApiContext): Promise { - return await makeRestApiRequest(context, 'GET', '/ldap/config'); -} - -export async function testLdapConnection(context: IRestApiContext): Promise<{}> { - return await makeRestApiRequest(context, 'POST', '/ldap/test-connection'); -} - -export async function updateLdapConfig( - context: IRestApiContext, - adConfig: ILdapConfig, -): Promise { - return await makeRestApiRequest( - context, - 'PUT', - '/ldap/config', - adConfig as unknown as IDataObject, - ); -} - -export async function runLdapSync(context: IRestApiContext, data: IDataObject): Promise<{}> { - return await makeRestApiRequest(context, 'POST', '/ldap/sync', data as unknown as IDataObject); -} - -export async function getLdapSynchronizations( - context: IRestApiContext, - pagination: { page: number }, -): Promise { - return await makeRestApiRequest(context, 'GET', '/ldap/sync', pagination); -} diff --git a/packages/frontend/editor-ui/src/stores/settings.store.ts b/packages/frontend/editor-ui/src/stores/settings.store.ts index 1ec1a4051ed..9b7186fe105 100644 --- a/packages/frontend/editor-ui/src/stores/settings.store.ts +++ b/packages/frontend/editor-ui/src/stores/settings.store.ts @@ -3,10 +3,10 @@ import Bowser from 'bowser'; import type { IUserManagementSettings, FrontendSettings } from '@n8n/api-types'; import * as eventsApi from '@n8n/rest-api-client/api/events'; -import * as ldapApi from '@/api/ldap'; +import * as ldapApi from '@n8n/rest-api-client/api/ldap'; import * as settingsApi from '@/api/settings'; import { testHealthEndpoint } from '@/api/templates'; -import type { ILdapConfig } from '@/Interface'; +import type { LdapConfig } from '@n8n/rest-api-client/api/ldap'; import { INSECURE_CONNECTION_WARNING, LOCAL_STORAGE_EXPERIMENTAL_MIN_ZOOM_NODE_SETTINGS_IN_CANVAS, @@ -363,7 +363,7 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => { return await ldapApi.testLdapConnection(rootStore.restApiContext); }; - const updateLdapConfig = async (ldapConfig: ILdapConfig) => { + const updateLdapConfig = async (ldapConfig: LdapConfig) => { const rootStore = useRootStore(); return await ldapApi.updateLdapConfig(rootStore.restApiContext, ldapConfig); }; diff --git a/packages/frontend/editor-ui/src/views/SettingsLdapView.vue b/packages/frontend/editor-ui/src/views/SettingsLdapView.vue index cae5392cb75..f2c4a8b1996 100644 --- a/packages/frontend/editor-ui/src/views/SettingsLdapView.vue +++ b/packages/frontend/editor-ui/src/views/SettingsLdapView.vue @@ -6,13 +6,8 @@ import { convertToDisplayDate } from '@/utils/typesUtils'; import { useToast } from '@/composables/useToast'; import { useMessage } from '@/composables/useMessage'; import { useDocumentTitle } from '@/composables/useDocumentTitle'; -import type { - ILdapConfig, - ILdapSyncData, - ILdapSyncTable, - IFormInput, - IFormInputs, -} from '@/Interface'; +import type { IFormInput, IFormInputs } from '@/Interface'; +import type { LdapConfig, LdapSyncData, LdapSyncTable } from '@n8n/rest-api-client/api/ldap'; import { MODAL_CONFIRM } from '@/constants'; import humanizeDuration from 'humanize-duration'; @@ -71,9 +66,9 @@ const pageRedirectionHelper = usePageRedirectionHelper(); const settingsStore = useSettingsStore(); -const dataTable = ref([]); +const dataTable = ref([]); const tableKey = ref(0); -const adConfig = ref(); +const adConfig = ref(); const loadingTestConnection = ref(false); const loadingDryRun = ref(false); const loadingLiveRun = ref(false); @@ -123,7 +118,7 @@ const onReadyToSubmit = (ready: boolean) => { readyToSubmit.value = ready; }; -const syncDataMapper = (sync: ILdapSyncData): ILdapSyncTable => { +const syncDataMapper = (sync: LdapSyncData): LdapSyncTable => { const startedAt = new Date(sync.startedAt); const endedAt = new Date(sync.endedAt); const runTimeInMinutes = endedAt.getTime() - startedAt.getTime(); @@ -149,7 +144,7 @@ const onSubmit = async () => { const formValues = ldapConfigFormRef.value.getValues(); - const newConfiguration: ILdapConfig = { + const newConfiguration: LdapConfig = { loginEnabled: formValues.loginEnabled, loginLabel: formValues.loginLabel, connectionUrl: formValues.serverAddress,