feat: Add SSO SAML metadataUrl support and various improvements (#6139)

* feat: add various sso improvements

* fix: remove test button assertion

* fix: fix type imports

* test: attempt fixing unit tests

* fix: changed to using useToast for error toasts

* Minor copy tweaks and swapped buttons position.

* fix locale ref

* align error with UI wording

* simplify saving ux

* fix pretty

* fix: update saml sso setting saving

* fix: undo try/catch changes when saving saml config

* metadata url tab selected at first

* chore: fix linting issue

* test: fix activation checkbox test

---------

Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
Co-authored-by: Michael Auerswald <michael.auerswald@gmail.com>
Co-authored-by: Romain Minaud <romain.minaud@gmail.com>
This commit is contained in:
Alex Grozav
2023-05-23 16:25:28 +03:00
committed by GitHub
parent 4b854333d4
commit e3a53fd19d
8 changed files with 264 additions and 118 deletions

View File

@@ -6,6 +6,7 @@ import { useSettingsStore } from '@/stores/settings.store';
import * as ssoApi from '@/api/sso';
import type { SamlPreferences } from '@/Interface';
import { updateCurrentUser } from '@/api/users';
import type { SamlPreferencesExtractedData } from '@/Interface';
import { useUsersStore } from '@/stores/users.store';
export const useSSOStore = defineStore('sso', () => {
@@ -15,10 +16,13 @@ export const useSSOStore = defineStore('sso', () => {
const state = reactive({
loading: false,
samlConfig: undefined as (SamlPreferences & SamlPreferencesExtractedData) | undefined,
});
const isLoading = computed(() => state.loading);
const samlConfig = computed(() => state.samlConfig);
const setLoading = (loading: boolean) => {
state.loading = loading;
};
@@ -56,7 +60,11 @@ export const useSSOStore = defineStore('sso', () => {
ssoApi.toggleSamlConfig(rootStore.getRestApiContext, { loginEnabled: enabled });
const getSamlMetadata = async () => ssoApi.getSamlMetadata(rootStore.getRestApiContext);
const getSamlConfig = async () => ssoApi.getSamlConfig(rootStore.getRestApiContext);
const getSamlConfig = async () => {
const samlConfig = await ssoApi.getSamlConfig(rootStore.getRestApiContext);
state.samlConfig = samlConfig;
return samlConfig;
};
const saveSamlConfig = async (config: SamlPreferences) =>
ssoApi.saveSamlConfig(rootStore.getRestApiContext, config);
const testSamlConfig = async () => ssoApi.testSamlConfig(rootStore.getRestApiContext);
@@ -77,6 +85,7 @@ export const useSSOStore = defineStore('sso', () => {
isEnterpriseSamlEnabled,
isDefaultAuthenticationSaml,
showSsoLoginButton,
samlConfig,
getSSORedirectUrl,
getSamlMetadata,
getSamlConfig,