feat(editor): SSO setup (#5736)
* feat(editor): SSO settings page * feat(editor): SSO settings page * feat(editor): SSO settings page * feat(editor): SSO settings page * feat(editor): SSO settings page * feat(editor): SSO settings page * Merge remote-tracking branch 'origin/master' into pay-170-sso-set-up-page # Conflicts: # packages/cli/src/sso/saml/routes/saml.controller.ee.ts * feat(editor): Prevent SSO settings page route * feat(editor): some UI improvements * fix(editor): SSO settings saml config optional chaining * fix return values saml controller * fix(editor): drop dompurify * fix(editor): save xml as is * return authenticationMethod with settings * fix(editor): add missing prop to server * chore(editor): code formatting * fix ldap/saml enable toggle endpoint * fix missing import * prevent faulty ldap setting from breaking startup * remove sso fake-door from users page * fix(editor): update SSO settings route permissions + unit testing * fix(editor): update vite config for test * fix(editor): add paddings to SSO settings page buttons, add translation * fix(editor): fix saml unit test * fix(core): Improve saml test connection function (#5899) improve-saml-test-connection return --------- Co-authored-by: Michael Auerswald <michael.auerswald@gmail.com> Co-authored-by: Romain Minaud <romain.minaud@gmail.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { computed, reactive } from 'vue';
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
import { EnterpriseEditionFeature } from '@/constants';
|
||||
import { useRootStore } from '@/stores/n8nRootStore';
|
||||
import { useSettingsStore } from '@/stores/settings';
|
||||
import { initSSO } from '@/api/sso';
|
||||
import * as ssoApi from '@/api/sso';
|
||||
import { SamlPreferences } from '@/Interface';
|
||||
|
||||
export const useSSOStore = defineStore('sso', () => {
|
||||
const rootStore = useRootStore();
|
||||
@@ -19,7 +20,22 @@ export const useSSOStore = defineStore('sso', () => {
|
||||
state.loading = loading;
|
||||
};
|
||||
|
||||
const isSamlLoginEnabled = computed(() => settingsStore.isSamlLoginEnabled);
|
||||
const isSamlLoginEnabled = computed({
|
||||
get: () => settingsStore.isSamlLoginEnabled,
|
||||
set: (value: boolean) => {
|
||||
settingsStore.setSettings({
|
||||
...settingsStore.settings,
|
||||
sso: {
|
||||
...settingsStore.settings.sso,
|
||||
saml: {
|
||||
...settingsStore.settings.sso.saml,
|
||||
loginEnabled: value,
|
||||
},
|
||||
},
|
||||
});
|
||||
toggleLoginEnabled(value);
|
||||
},
|
||||
});
|
||||
const isEnterpriseSamlEnabled = computed(() =>
|
||||
settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.Saml),
|
||||
);
|
||||
@@ -31,12 +47,27 @@ export const useSSOStore = defineStore('sso', () => {
|
||||
isDefaultAuthenticationSaml.value,
|
||||
);
|
||||
|
||||
const getSSORedirectUrl = () => initSSO(rootStore.getRestApiContext);
|
||||
const getSSORedirectUrl = () => ssoApi.initSSO(rootStore.getRestApiContext);
|
||||
|
||||
const toggleLoginEnabled = (enabled: boolean) =>
|
||||
ssoApi.toggleSamlConfig(rootStore.getRestApiContext, { loginEnabled: enabled });
|
||||
|
||||
const getSamlMetadata = () => ssoApi.getSamlMetadata(rootStore.getRestApiContext);
|
||||
const getSamlConfig = () => ssoApi.getSamlConfig(rootStore.getRestApiContext);
|
||||
const saveSamlConfig = (config: SamlPreferences) =>
|
||||
ssoApi.saveSamlConfig(rootStore.getRestApiContext, config);
|
||||
const testSamlConfig = () => ssoApi.testSamlConfig(rootStore.getRestApiContext);
|
||||
|
||||
return {
|
||||
isLoading,
|
||||
setLoading,
|
||||
isSamlLoginEnabled,
|
||||
isEnterpriseSamlEnabled,
|
||||
showSsoLoginButton,
|
||||
getSSORedirectUrl,
|
||||
getSamlMetadata,
|
||||
getSamlConfig,
|
||||
saveSamlConfig,
|
||||
testSamlConfig,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user