feat(core): Add LDAP support (#3835)

This commit is contained in:
Ricardo Espinoza
2023-01-24 20:18:39 -05:00
committed by GitHub
parent 259296c5c9
commit 0c70a40317
77 changed files with 3686 additions and 192 deletions

View File

@@ -1,4 +1,11 @@
import { createApiKey, deleteApiKey, getApiKey } from '@/api/api-keys';
import {
getLdapConfig,
getLdapSynchronizations,
runLdapSync,
testLdapConnection,
updateLdapConfig,
} from '@/api/ldap';
import { getPromptsData, getSettings, submitContactInfo, submitValueSurvey } from '@/api/settings';
import { testHealthEndpoint } from '@/api/templates';
import {
@@ -15,6 +22,7 @@ import {
IN8nValueSurveyData,
ISettingsState,
WorkflowCallerPolicyDefaultOption,
ILdapConfig,
} from '@/Interface';
import { ITelemetrySettings } from 'n8n-workflow';
import { defineStore } from 'pinia';
@@ -42,6 +50,10 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, {
enabled: false,
},
},
ldap: {
loginLabel: '',
loginEnabled: false,
},
onboardingCallPromptEnabled: false,
saveDataErrorExecution: 'all',
saveDataSuccessExecution: 'all',
@@ -69,6 +81,12 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, {
publicApiPath(): string {
return this.api.path;
},
isLdapLoginEnabled(): boolean {
return this.ldap.loginEnabled;
},
ldapLoginLabel(): string {
return this.ldap.loginLabel;
},
showSetupPage(): boolean {
return this.userManagement.showSetupOnFirstLoad === true;
},
@@ -147,6 +165,8 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, {
this.userManagement.smtpSetup = settings.userManagement.smtpSetup;
this.api = settings.publicApi;
this.onboardingCallPromptEnabled = settings.onboardingCallPromptEnabled;
this.ldap.loginEnabled = settings.ldap.loginEnabled;
this.ldap.loginLabel = settings.ldap.loginLabel;
},
async getSettings(): Promise<void> {
const rootStore = useRootStore();
@@ -253,6 +273,26 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, {
const rootStore = useRootStore();
await deleteApiKey(rootStore.getRestApiContext);
},
async getLdapConfig() {
const rootStore = useRootStore();
return await getLdapConfig(rootStore.getRestApiContext);
},
async getLdapSynchronizations(pagination: { page: number }) {
const rootStore = useRootStore();
return await getLdapSynchronizations(rootStore.getRestApiContext, pagination);
},
async testLdapConnection() {
const rootStore = useRootStore();
return await testLdapConnection(rootStore.getRestApiContext);
},
async updateLdapConfig(ldapConfig: ILdapConfig) {
const rootStore = useRootStore();
return await updateLdapConfig(rootStore.getRestApiContext, ldapConfig);
},
async runLdapSync(data: IDataObject) {
const rootStore = useRootStore();
return await runLdapSync(rootStore.getRestApiContext, data);
},
setSaveDataErrorExecution(newValue: string) {
Vue.set(this, 'saveDataErrorExecution', newValue);
},

View File

@@ -38,6 +38,7 @@ import { useUIStore } from './ui';
const isDefaultUser = (user: IUserResponse | null) =>
Boolean(user && user.isPending && user.globalRole && user.globalRole.name === ROLE.Owner);
const isPendingUser = (user: IUserResponse | null) => Boolean(user && user.isPending);
export const useUsersStore = defineStore(STORES.USERS, {
@@ -58,8 +59,8 @@ export const useUsersStore = defineStore(STORES.USERS, {
getUserById(state) {
return (userId: string): IUser | null => state.users[userId];
},
globalRoleName(): string {
return this.currentUser?.globalRole?.name || '';
globalRoleName(): IRole {
return this.currentUser?.globalRole?.name ?? 'default';
},
canUserDeleteTags(): boolean {
return isAuthorized(PERMISSIONS.TAGS.CAN_DELETE_TAGS, this.currentUser);
@@ -116,7 +117,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
: undefined,
isDefaultUser: isDefaultUser(updatedUser),
isPendingUser: isPendingUser(updatedUser),
isOwner: Boolean(updatedUser.globalRole && updatedUser.globalRole.name === ROLE.Owner),
isOwner: updatedUser.globalRole?.name === ROLE.Owner,
};
Vue.set(this.users, user.id, user);
});