Skip to content

Commit

Permalink
Merge pull request #363 from richard-cox/embedded-prod
Browse files Browse the repository at this point in the history
Ensure dex redirect url is correct when running in production
  • Loading branch information
richard-cox authored Nov 17, 2023
2 parents 0a76d5c + 3cb9af3 commit c38eabb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion dashboard/pkg/epinio/models/cluster.ts
Original file line number Diff line number Diff line change
@@ -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`;

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pkg/epinio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion dashboard/pkg/epinio/pages/auth/verify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -25,7 +26,7 @@ export default Vue.extend<Data, any, any, any>({
} else {
await epinioAuth.dexRedirect(route, {
dexUrl: document.referrer,
dashboardUrl: window.origin
dashboardUrl: dashboardUrl()
});
}
},
Expand Down
9 changes: 9 additions & 0 deletions dashboard/pkg/epinio/utils/embedded-helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const dashboardUrl = () => {
const dashboardUrl = window.origin;

if (process.env.dev) {
return dashboardUrl;
}

return `${ dashboardUrl }/dashboard`;
};
3 changes: 2 additions & 1 deletion dashboard/pkg/epinio/utils/epinio-discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -21,7 +22,7 @@ export default {
type: EpinioAuthTypes.AGNOSTIC,
epinioUrl: url,
dexConfig: {
dashboardUrl: window.origin,
dashboardUrl: dashboardUrl(),
dexUrl: url.replace('epinio', 'auth')
},
});
Expand Down

0 comments on commit c38eabb

Please sign in to comment.