Skip to content

Commit

Permalink
centraldashboard: Support dynamic logout URL
Browse files Browse the repository at this point in the history
Use dynamic URL for the logout button that can be set by the LOGOUT_URL
ENV variable in the deployment of the app. If it is unset, a default
'/logout' string is passed from the backend to the frontend.

Signed-off-by: Orfeas Kourkakis <orfeas@arrikto.com>
  • Loading branch information
Orfeas Kourkakis committed Feb 10, 2023
1 parent 1552c90 commit 9356553
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 10 deletions.
7 changes: 5 additions & 2 deletions components/centraldashboard/app/k8s_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import * as k8s from '@kubernetes/client-node';

/** Retrieve Dashboard configmap Name */
const {
DASHBOARD_CONFIGMAP = "centraldashboard-config"
DASHBOARD_CONFIGMAP = "centraldashboard-config",
LOGOUT_URL = '/logout'
} = process.env;

/** Information about the Kubernetes hosting platform. */
export interface PlatformInfo {
provider: string;
providerName: string;
kubeflowVersion: string;
logoutUrl: string;
}

/**
Expand Down Expand Up @@ -111,7 +113,8 @@ export class KubernetesService {
return {
kubeflowVersion: version,
provider,
providerName: provider.split(':')[0]
providerName: provider.split(':')[0],
logoutUrl : LOGOUT_URL,
};
} catch (err) {
console.error('Unexpected error', err);
Expand Down
12 changes: 8 additions & 4 deletions components/centraldashboard/app/k8s_service_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ describe('KubernetesService', () => {
provider:
'gce://kubeflow-dev/us-east1-d/gke-kubeflow-default-pool-59885f2c-08tm',
providerName: 'gce',
kubeflowVersion: '1.0.0'
kubeflowVersion: '1.0.0',
logoutUrl: '/logout'
});
});

Expand Down Expand Up @@ -269,7 +270,8 @@ describe('KubernetesService', () => {
expect(platformInfo).toEqual({
provider: 'other://',
providerName: 'other',
kubeflowVersion: '1.0.0'
kubeflowVersion: '1.0.0',
logoutUrl: '/logout'
});
});

Expand Down Expand Up @@ -316,7 +318,8 @@ describe('KubernetesService', () => {
provider:
'gce://kubeflow-dev/us-east1-d/gke-kubeflow-default-pool-59885f2c-08tm',
providerName: 'gce',
kubeflowVersion: 'unknown'
kubeflowVersion: 'unknown',
logoutUrl: '/logout'
});
});

Expand All @@ -330,7 +333,8 @@ describe('KubernetesService', () => {
expect(platformInfo).toEqual({
provider: 'other://',
providerName: 'other',
kubeflowVersion: 'unknown'
kubeflowVersion: 'unknown',
logoutUrl: '/logout'
});
});
});
Expand Down
2 changes: 2 additions & 0 deletions components/centraldashboard/manifests/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ spec:
value: $(CD_REGISTRATION_FLOW)
- name: DASHBOARD_LINKS_CONFIGMAP
value: $(CD_CONFIGMAP_NAME)
- name: LOGOUT_URL
value: '/authservice/logout'
serviceAccountName: centraldashboard
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export class LogoutButton extends PolymerElement {
static get template() {
return html`
<paper-button id="logout-button" on-tap="logout">
<iron-icon icon='kubeflow:logout' title="Logout"
<iron-icon icon='kubeflow:logout' title="Logout">
</iron-icon>
</paper-button>
<iron-ajax
id='logout'
url='/logout'
url$='{{logoutUrl}}'
method='post'
handle-as='json'
headers='{{headers}}'
Expand All @@ -33,6 +33,9 @@ export class LogoutButton extends PolymerElement {
type: Object,
computed: '_setHeaders()',
},
logoutUrl: {
type: String,
},
};
}

Expand Down
4 changes: 4 additions & 0 deletions components/centraldashboard/public/components/main-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class MainPage extends utilitiesMixin(PolymerElement) {
errorText: {type: String, value: ''},
buildVersion: {type: String, value: BUILD_VERSION},
dashVersion: {type: String, value: VERSION},
logoutUrl: {type: String, value: '/logout'},
platformInfo: Object,
inIframe: {type: Boolean, value: false, readOnly: true},
hideTabs: {type: Boolean, value: false, readOnly: true},
Expand Down Expand Up @@ -476,6 +477,9 @@ export class MainPage extends utilitiesMixin(PolymerElement) {
if (kVer && kVer != 'unknown') {
this.buildVersion = this.platformInfo.kubeflowVersion;
}
if (platform.logoutUrl) {
this.logoutUrl = platform.logoutUrl;
}
// trigger template render
this.menuLinks = JSON.parse(JSON.stringify(this.menuLinks));
this._enableAllNamespaceOption();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ app-drawer-layout.flex(narrow='{{narrowMode}}',
all-namespaces='[[allNamespaces]]',
user='[[user]]')
footer#User-Badge
logout-button
logout-button(logout-url='[[logoutUrl]]')
main#Content
section#ViewTabs(hidden$='[[hideTabs]]')
paper-tabs(selected='[[page]]', attr-for-selected='page')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {html, PolymerElement} from '@polymer/polymer/polymer-element.js';

export const ALL_NAMESPACES = 'All namespaces';
export const ALL_NAMESPACES_ALLOWED_LIST = ['jupyter', 'volumes',
'tensorboards'];
'tensorboards'];

const allNamespacesAllowedPaths = ALL_NAMESPACES_ALLOWED_LIST
.map(( p)=>`/_/${p}/`);
Expand Down

0 comments on commit 9356553

Please sign in to comment.