mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 12:19:09 +00:00
fix(editor): Use redirect url also with SSO login (#14893)
This commit is contained in:
@@ -164,7 +164,7 @@ export class SamlController {
|
|||||||
* This endpoint is available if SAML is licensed and enabled
|
* This endpoint is available if SAML is licensed and enabled
|
||||||
*/
|
*/
|
||||||
@Get('/initsso', { middlewares: [samlLicensedAndEnabledMiddleware], skipAuth: true })
|
@Get('/initsso', { middlewares: [samlLicensedAndEnabledMiddleware], skipAuth: true })
|
||||||
async initSsoGet(req: AuthlessRequest, res: Response) {
|
async initSsoGet(req: AuthlessRequest<{}, {}, {}, { redirect?: string }>, res: Response) {
|
||||||
let redirectUrl = '';
|
let redirectUrl = '';
|
||||||
try {
|
try {
|
||||||
const refererUrl = req.headers.referer;
|
const refererUrl = req.headers.referer;
|
||||||
@@ -180,7 +180,7 @@ export class SamlController {
|
|||||||
} catch {
|
} catch {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
return await this.handleInitSSO(res, redirectUrl);
|
return await this.handleInitSSO(res, redirectUrl || (req.query.redirect ?? ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import type { SamlPreferences, SamlToggleDto } from '@n8n/api-types';
|
|||||||
import { makeRestApiRequest } from '@/utils/apiUtils';
|
import { makeRestApiRequest } from '@/utils/apiUtils';
|
||||||
import type { IRestApiContext, SamlPreferencesExtractedData } from '@/Interface';
|
import type { IRestApiContext, SamlPreferencesExtractedData } from '@/Interface';
|
||||||
|
|
||||||
export const initSSO = async (context: IRestApiContext): Promise<string> => {
|
export const initSSO = async (context: IRestApiContext, redirectUrl = ''): Promise<string> => {
|
||||||
return await makeRestApiRequest(context, 'GET', '/sso/saml/initsso');
|
return await makeRestApiRequest(context, 'GET', `/sso/saml/initsso?redirect=${redirectUrl}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getSamlMetadata = async (context: IRestApiContext): Promise<SamlPreferences> => {
|
export const getSamlMetadata = async (context: IRestApiContext): Promise<SamlPreferences> => {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { SamlPreferences } from '@n8n/api-types';
|
import type { SamlPreferences } from '@n8n/api-types';
|
||||||
import { computed, reactive } from 'vue';
|
import { computed, reactive } from 'vue';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { EnterpriseEditionFeature } from '@/constants';
|
import { EnterpriseEditionFeature } from '@/constants';
|
||||||
import { useRootStore } from '@/stores/root.store';
|
import { useRootStore } from '@/stores/root.store';
|
||||||
@@ -13,6 +14,7 @@ export const useSSOStore = defineStore('sso', () => {
|
|||||||
const rootStore = useRootStore();
|
const rootStore = useRootStore();
|
||||||
const settingsStore = useSettingsStore();
|
const settingsStore = useSettingsStore();
|
||||||
const usersStore = useUsersStore();
|
const usersStore = useUsersStore();
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
loading: false,
|
loading: false,
|
||||||
@@ -54,7 +56,11 @@ export const useSSOStore = defineStore('sso', () => {
|
|||||||
isDefaultAuthenticationSaml.value,
|
isDefaultAuthenticationSaml.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
const getSSORedirectUrl = async () => await ssoApi.initSSO(rootStore.restApiContext);
|
const getSSORedirectUrl = async () =>
|
||||||
|
await ssoApi.initSSO(
|
||||||
|
rootStore.restApiContext,
|
||||||
|
typeof route.query?.redirect === 'string' ? route.query.redirect : '',
|
||||||
|
);
|
||||||
|
|
||||||
const toggleLoginEnabled = async (enabled: boolean) =>
|
const toggleLoginEnabled = async (enabled: boolean) =>
|
||||||
await ssoApi.toggleSamlConfig(rootStore.restApiContext, { loginEnabled: enabled });
|
await ssoApi.toggleSamlConfig(rootStore.restApiContext, { loginEnabled: enabled });
|
||||||
|
|||||||
Reference in New Issue
Block a user