From 825b555f06eb9dfb987dee1d072bba6874552a8a Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Mon, 13 May 2019 14:03:08 -0400 Subject: [PATCH] 15064: Logging into home cluster logs into all federated clusters Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- src/services/auth-service/auth-service.ts | 5 +++-- src/store/auth/auth-action.ts | 12 ++++++------ src/views-components/main-app-bar/anonymous-menu.tsx | 2 +- src/views/login-panel/login-panel.tsx | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/services/auth-service/auth-service.ts b/src/services/auth-service/auth-service.ts index eae219dd..cec0cef1 100644 --- a/src/services/auth-service/auth-service.ts +++ b/src/services/auth-service/auth-service.ts @@ -108,9 +108,10 @@ export class AuthService { localStorage.removeItem(USER_PREFS); } - public login(uuidPrefix: string, homeCluster: string) { + public login(uuidPrefix: string, homeCluster: string, remoteHosts: { [key: string]: string }) { const currentUrl = `${window.location.protocol}//${window.location.host}/token`; - window.location.assign(`https://${homeCluster}/login?remote=${uuidPrefix}&return_to=${currentUrl}`); + const homeClusterHost = remoteHosts[homeCluster]; + window.location.assign(`https://${homeClusterHost}/login?${uuidPrefix !== homeCluster ? "remote=" + uuidPrefix + "&" : ""}return_to=${currentUrl}`); } public logout() { diff --git a/src/store/auth/auth-action.ts b/src/store/auth/auth-action.ts index 09d922e0..1605e302 100644 --- a/src/store/auth/auth-action.ts +++ b/src/store/auth/auth-action.ts @@ -59,11 +59,11 @@ export const initAuth = (config: Config) => (dispatch: Dispatch, getState: () => dispatch(getUserDetails()).then((user: User) => { dispatch(authActions.INIT({ user, token })); }); - Object.keys(config.remoteHosts).map((k) => { - Axios.get(getDiscoveryURL(config.remoteHosts[k])) - .then(response => dispatch(authActions.REMOTE_CLUSTER_CONFIG({ config: response.data }))); - }); } + Object.keys(config.remoteHosts).map((k) => { + Axios.get(getDiscoveryURL(config.remoteHosts[k])) + .then(response => dispatch(authActions.REMOTE_CLUSTER_CONFIG({ config: response.data }))); + }); }; export const saveApiToken = (token: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { @@ -72,8 +72,8 @@ export const saveApiToken = (token: string) => (dispatch: Dispatch, getState: () dispatch(authActions.SAVE_API_TOKEN(token)); }; -export const login = (uuidPrefix: string, homeCluster: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - services.authService.login(uuidPrefix, homeCluster); +export const login = (uuidPrefix: string, homeCluster: string, remoteHosts: { [key: string]: string }) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + services.authService.login(uuidPrefix, homeCluster, remoteHosts); dispatch(authActions.LOGIN()); }; diff --git a/src/views-components/main-app-bar/anonymous-menu.tsx b/src/views-components/main-app-bar/anonymous-menu.tsx index 5ffc4215..15329a43 100644 --- a/src/views-components/main-app-bar/anonymous-menu.tsx +++ b/src/views-components/main-app-bar/anonymous-menu.tsx @@ -11,6 +11,6 @@ export const AnonymousMenu = connect()( ({ dispatch }: DispatchProp) => ); diff --git a/src/views/login-panel/login-panel.tsx b/src/views/login-panel/login-panel.tsx index b9f3194a..41a17bf9 100644 --- a/src/views/login-panel/login-panel.tsx +++ b/src/views/login-panel/login-panel.tsx @@ -93,7 +93,7 @@ export const LoginPanel = withStyles(styles)(