15064: Logging into home cluster logs into all federated clusters
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Mon, 13 May 2019 18:03:08 +0000 (14:03 -0400)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Mon, 13 May 2019 18:03:08 +0000 (14:03 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz@veritasgenetics.com>

src/services/auth-service/auth-service.ts
src/store/auth/auth-action.ts
src/views-components/main-app-bar/anonymous-menu.tsx
src/views/login-panel/login-panel.tsx

index eae219dd0ad2a547883b94047a961d10048f5019..cec0cef1d86538a8337bc678a5422a9fec95d1c5 100644 (file)
@@ -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() {
index 09d922e05282ba0809272bca22a238d77e39c29f..1605e302f908e98fd1dde759a5d1965c4c702f0a 100644 (file)
@@ -59,11 +59,11 @@ export const initAuth = (config: Config) => (dispatch: Dispatch, getState: () =>
         dispatch<any>(getUserDetails()).then((user: User) => {
             dispatch(authActions.INIT({ user, token }));
         });
-        Object.keys(config.remoteHosts).map((k) => {
-            Axios.get<Config>(getDiscoveryURL(config.remoteHosts[k]))
-                .then(response => dispatch(authActions.REMOTE_CLUSTER_CONFIG({ config: response.data })));
-        });
     }
+    Object.keys(config.remoteHosts).map((k) => {
+        Axios.get<Config>(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());
 };
 
index 5ffc42158acb1c9f5fbc04cd0d1f6aedaa7cfdad..15329a43e9119850a8fce69b759319c7f5f69015 100644 (file)
@@ -11,6 +11,6 @@ export const AnonymousMenu = connect()(
     ({ dispatch }: DispatchProp<any>) =>
         <Button
             color="inherit"
-            onClick={() => dispatch(login("", ""))}>
+            onClick={() => dispatch(login("", "", {}))}>
             Sign in
         </Button>);
index b9f3194ab0b2aa12fc375a7ac5f966dc6630db1a..41a17bf9682c1b7fb86d5436097ac24673b19693 100644 (file)
@@ -93,7 +93,7 @@ export const LoginPanel = withStyles(styles)(
 
                 <Typography component="div" align="right">
                     <Button variant="contained" color="primary" style={{ margin: "1em" }} className={classes.button}
-                        onClick={() => dispatch(login(uuidPrefix, remoteHosts[homeCluster]))}>
+                        onClick={() => dispatch(login(uuidPrefix, homeCluster, remoteHosts))}>
                         Log in to {uuidPrefix}
                         {uuidPrefix !== homeCluster &&
                             <span>&nbsp;with user from {homeCluster}</span>}