From 3cb9af310146c54a65679a5c635e40a3fe87b101 Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Thu, 16 Nov 2023 17:22:03 +0000 Subject: [PATCH] Ensure dex redirect url is correct when running in production --- dashboard/pkg/epinio/models/cluster.ts | 3 ++- dashboard/pkg/epinio/package.json | 2 +- dashboard/pkg/epinio/pages/auth/verify.vue | 3 ++- dashboard/pkg/epinio/utils/embedded-helpers.ts | 9 +++++++++ dashboard/pkg/epinio/utils/epinio-discovery.ts | 3 ++- 5 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 dashboard/pkg/epinio/utils/embedded-helpers.ts diff --git a/dashboard/pkg/epinio/models/cluster.ts b/dashboard/pkg/epinio/models/cluster.ts index 06d747b..2854d61 100644 --- a/dashboard/pkg/epinio/models/cluster.ts +++ b/dashboard/pkg/epinio/models/cluster.ts @@ -1,6 +1,7 @@ import Resource from '@shell/plugins/dashboard-store/resource-class'; import { EPINIO_TYPES } from '../types'; import epinioAuth, { EpinioAuthConfig, EpinioAuthLocalConfig, EpinioAuthTypes } from '../utils/auth'; +import { dashboardUrl } from '../utils/embedded-helpers'; export const EpinioInfoPath = `/api/v1/info`; @@ -70,7 +71,7 @@ export default class EpinioCluster extends Resource { type, epinioUrl: this.api, dexConfig: { - dashboardUrl: window.origin, + dashboardUrl: dashboardUrl(), dexUrl: this.api.replace('epinio', 'auth') }, localConfig diff --git a/dashboard/pkg/epinio/package.json b/dashboard/pkg/epinio/package.json index 8fe09cf..32e5c7c 100644 --- a/dashboard/pkg/epinio/package.json +++ b/dashboard/pkg/epinio/package.json @@ -2,7 +2,7 @@ "name": "epinio", "description": "Application Development Engine for Kubernetes", "icon": "https://raw.githubusercontent.com/rancher/dashboard/0b6cbe93e9ed3292294da178f119a500cc494db9/pkg/epinio/assets/logo-epinio.svg", - "version": "1.11.0-1", + "version": "1.11.0-2", "private": false, "rancher": true, "license": "Apache-2.0", diff --git a/dashboard/pkg/epinio/pages/auth/verify.vue b/dashboard/pkg/epinio/pages/auth/verify.vue index ba78f30..65a592b 100644 --- a/dashboard/pkg/epinio/pages/auth/verify.vue +++ b/dashboard/pkg/epinio/pages/auth/verify.vue @@ -2,6 +2,7 @@ import Vue from 'vue'; import epinioAuth from '../../utils/auth'; import Banner from '@components/Banner/Banner.vue'; +import { dashboardUrl } from '../../utils/embedded-helpers'; interface Data { error: string, @@ -25,7 +26,7 @@ export default Vue.extend({ } else { await epinioAuth.dexRedirect(route, { dexUrl: document.referrer, - dashboardUrl: window.origin + dashboardUrl: dashboardUrl() }); } }, diff --git a/dashboard/pkg/epinio/utils/embedded-helpers.ts b/dashboard/pkg/epinio/utils/embedded-helpers.ts new file mode 100644 index 0000000..a46efad --- /dev/null +++ b/dashboard/pkg/epinio/utils/embedded-helpers.ts @@ -0,0 +1,9 @@ +export const dashboardUrl = () => { + const dashboardUrl = window.origin; + + if (process.env.dev) { + return dashboardUrl; + } + + return `${ dashboardUrl }/dashboard`; +}; diff --git a/dashboard/pkg/epinio/utils/epinio-discovery.ts b/dashboard/pkg/epinio/utils/epinio-discovery.ts index dcc2817..79a2beb 100644 --- a/dashboard/pkg/epinio/utils/epinio-discovery.ts +++ b/dashboard/pkg/epinio/utils/epinio-discovery.ts @@ -2,6 +2,7 @@ import { MANAGEMENT } from '@shell/config/types'; import { ingressFullPath } from '@shell/models/networking.k8s.io.ingress'; import epinioAuth, { EpinioAuthTypes } from '../utils/auth'; import EpinioCluster from '../models/cluster'; +import { dashboardUrl } from './embedded-helpers'; export default { ingressUrl(clusterId: string) { @@ -21,7 +22,7 @@ export default { type: EpinioAuthTypes.AGNOSTIC, epinioUrl: url, dexConfig: { - dashboardUrl: window.origin, + dashboardUrl: dashboardUrl(), dexUrl: url.replace('epinio', 'auth') }, });