Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

[Web Portal] remove pylon address dependency #3040

Merged
merged 2 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/webportal/deploy/webportal.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ spec:
image: {{ cluster_cfg['cluster']['docker-registry']['prefix'] }}webportal:{{ cluster_cfg['cluster']['docker-registry']['tag'] }}
imagePullPolicy: Always
env:
- name: PYLON_ADDRESS
value: {{ cluster_cfg['pylon']['uri'] }}
- name: REST_SERVER_URI
value: {{ cluster_cfg['rest-server']['uri'] }}
- name: PROMETHEUS_URI
Expand Down
24 changes: 14 additions & 10 deletions src/webportal/src/app/home/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'whatwg-fetch';
import {FontClassNames} from '@uifabric/styling';
import c from 'classnames';
import {initializeIcons} from 'office-ui-fabric-react';
import querystring from 'querystring';
import React, {useState, useCallback} from 'react';
import ReactDOM from 'react-dom';

Expand All @@ -36,15 +37,15 @@ import url from 'url';

const loginTarget = '/home.html';

if ( config.authnMethod === 'OIDC') {
const query = url.parse(window.location.href, true).query;
const expiration = 7;
if (query['token']) {
cookies.set('user', query.user, {expires: expiration});
cookies.set('token', query.token, {expires: expiration});
cookies.set('admin', query.admin, {expires: expiration});
cookies.set('hasGitHubPAT', query.hasGitHubPAT, {expires: expiration});
}
if (config.authnMethod === 'OIDC') {
const query = url.parse(window.location.href, true).query;
const expiration = 7;
if (query['token']) {
cookies.set('user', query.user, {expires: expiration});
cookies.set('token', query.token, {expires: expiration});
cookies.set('admin', query.admin, {expires: expiration});
cookies.set('hasGitHubPAT', query.hasGitHubPAT, {expires: expiration});
}
}

if (checkToken(false)) {
Expand Down Expand Up @@ -79,7 +80,10 @@ const Index = () => {
if (config.authnMethod === 'basic') {
setLoginModal(true);
} else {
location.href = config.restServerUri + '/api/v1/authn/oidc/login?redirect_uri=' + encodeURIComponent(config.pylonAddress+'/index.html')+ '&callback=' + encodeURIComponent(location.href);
location.href = config.restServerUri + `/api/v1/authn/oidc/login?${querystring.stringify({
redirect_uri: new URL('/index.html', window.location.href).href,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything is needed to be updated here?

state = decodeURIComponent(req.query.redirect_uri);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think express's req.query is already parsed by querystring or qs. You don't need to decode it twice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right,

callback: window.location.href,
})}`;
}
},
[],
Expand Down
2 changes: 1 addition & 1 deletion src/webportal/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-8.0.1.tgz#9712fa2ad124ac64668ab06ba847b1eaf83a03fd"
integrity sha512-cctMYH5RLbElaUpZn3IJaUj9QNQD8iXDnl7xNY6KB1aFD2ciJrwpo3kvZowIT75uA+silJFDnSR2kGakALUymg==

"@hapi/joi@^15.1.0":
"@hapi/joi@~15.1.0":
version "15.1.0"
resolved "https://registry.yarnpkg.com/@hapi/joi/-/joi-15.1.0.tgz#940cb749b5c55c26ab3b34ce362e82b6162c8e7a"
integrity sha512-n6kaRQO8S+kepUTbXL9O/UOL788Odqs38/VOfoCrATDtTvyfiO3fgjlSRaNkHabpTLgM7qru9ifqXlXbXk8SeQ==
Expand Down