From 0209f5e7f2ec688f545f5025bafee2f2ea90a71b Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Mon, 13 May 2019 12:29:04 -0400 Subject: [PATCH] 15064: create iframes that load /fedtoken with salted token Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- src/common/config.ts | 2 +- src/views/workbench/fed-login.tsx | 31 +++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/common/config.ts b/src/common/config.ts index 7abff5da..71b7774c 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -137,4 +137,4 @@ const getDefaultConfig = (): ConfigJSON => ({ }); export const DISCOVERY_URL = 'discovery/v1/apis/arvados/v1/rest'; -export const getDiscoveryURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/${DISCOVERY_URL}`; +export const getDiscoveryURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/${DISCOVERY_URL}?nocache=${(new Date()).getTime()}`; diff --git a/src/views/workbench/fed-login.tsx b/src/views/workbench/fed-login.tsx index 0e9b5308..399b419e 100644 --- a/src/views/workbench/fed-login.tsx +++ b/src/views/workbench/fed-login.tsx @@ -6,26 +6,41 @@ import * as React from 'react'; import { connect } from 'react-redux'; import { RootState } from '~/store/store'; import { AuthState } from '~/store/auth/auth-reducer'; +import { User } from "~/models/user"; import { getSaltedToken } from '~/store/auth/auth-action-session'; +import { Config } from '~/common/config'; export interface FedLoginProps { - auth: AuthState; + user?: User; + apiToken?: string; + homeCluster: string; + remoteHostsConfig: { [key: string]: Config }; } -const mapStateToProps = ({ auth }: RootState) => ({ auth }); +const mapStateToProps = ({ auth }: RootState) => ({ + user: auth.user, + apiToken: auth.apiToken, + remoteHostsConfig: auth.remoteHostsConfig, + homeCluster: auth.homeCluster, +}); export const FedLogin = connect(mapStateToProps)( class extends React.Component { render() { - const auth = this.props.auth; - const remoteHostsConfig = auth.remoteHostsConfig; - if (!auth.user || !auth.user.uuid.startsWith(auth.homeCluster)) { + const { apiToken, user, homeCluster, remoteHostsConfig } = this.props; + if (!apiToken || !user || !user.uuid.startsWith(homeCluster)) { return <>; } - return
+ const [, tokenUuid, token] = apiToken.split("/"); + return
{Object.keys(remoteHostsConfig) - .filter((k) => k !== auth.homeCluster) - .map((k) =>