mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 04:10:01 +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
|
||||
*/
|
||||
@Get('/initsso', { middlewares: [samlLicensedAndEnabledMiddleware], skipAuth: true })
|
||||
async initSsoGet(req: AuthlessRequest, res: Response) {
|
||||
async initSsoGet(req: AuthlessRequest<{}, {}, {}, { redirect?: string }>, res: Response) {
|
||||
let redirectUrl = '';
|
||||
try {
|
||||
const refererUrl = req.headers.referer;
|
||||
@@ -180,7 +180,7 @@ export class SamlController {
|
||||
} catch {
|
||||
// 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 type { IRestApiContext, SamlPreferencesExtractedData } from '@/Interface';
|
||||
|
||||
export const initSSO = async (context: IRestApiContext): Promise<string> => {
|
||||
return await makeRestApiRequest(context, 'GET', '/sso/saml/initsso');
|
||||
export const initSSO = async (context: IRestApiContext, redirectUrl = ''): Promise<string> => {
|
||||
return await makeRestApiRequest(context, 'GET', `/sso/saml/initsso?redirect=${redirectUrl}`);
|
||||
};
|
||||
|
||||
export const getSamlMetadata = async (context: IRestApiContext): Promise<SamlPreferences> => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { SamlPreferences } from '@n8n/api-types';
|
||||
import { computed, reactive } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { defineStore } from 'pinia';
|
||||
import { EnterpriseEditionFeature } from '@/constants';
|
||||
import { useRootStore } from '@/stores/root.store';
|
||||
@@ -13,6 +14,7 @@ export const useSSOStore = defineStore('sso', () => {
|
||||
const rootStore = useRootStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
const usersStore = useUsersStore();
|
||||
const route = useRoute();
|
||||
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
@@ -54,7 +56,11 @@ export const useSSOStore = defineStore('sso', () => {
|
||||
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) =>
|
||||
await ssoApi.toggleSamlConfig(rootStore.restApiContext, { loginEnabled: enabled });
|
||||
|
||||
Reference in New Issue
Block a user