X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/98adeb294aa8bf1c1691f70ab095d20a96c0d375..7e9513099881d63a99a70c69ddd71c5d83567fa4:/src/views/workbench/fed-login.tsx

diff --git a/src/views/workbench/fed-login.tsx b/src/views/workbench/fed-login.tsx
index d77ddfb0d2..595f136b80 100644
--- a/src/views/workbench/fed-login.tsx
+++ b/src/views/workbench/fed-login.tsx
@@ -2,13 +2,12 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
+import 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';
+import { RootState } from 'store/store';
+import { User } from "models/user";
+import { getSaltedToken } from 'store/auth/auth-action-session';
+import { Config } from 'common/config';
 
 export interface FedLoginProps {
     user?: User;
@@ -31,16 +30,25 @@ export const FedLogin = connect(mapStateToProps)(
             if (!apiToken || !user || !user.uuid.startsWith(localCluster)) {
                 return <></>;
             }
-            const [, tokenUuid, token] = apiToken.split("/");
             return <div id={"fedtoken-iframe-div"}>
                 {Object.keys(remoteHostsConfig)
-                    .map((k) => k !== localCluster && remoteHostsConfig[k].workbench2Url &&
-                        <iframe key={k} src={`${remoteHostsConfig[k].workbench2Url}/fedtoken?api_token=${getSaltedToken(k, tokenUuid, token)}`} style={{
+                    .map((k) => {
+                        if (k === localCluster) {
+                            return null;
+                        }
+                        if (!remoteHostsConfig[k].workbench2Url) {
+                            console.log(`Cluster ${k} does not define workbench2Url.  Federated login / cross-site linking to ${k} is unavailable.  Tell the admin of ${k} to set Services->Workbench2->ExternalURL in config.yml.`);
+                            return null;
+                        }
+                        const fedtoken = (remoteHostsConfig[k].loginCluster === localCluster)
+                            ? apiToken : getSaltedToken(k, apiToken);
+                        return <iframe key={k} title={k} src={`${remoteHostsConfig[k].workbench2Url}/fedtoken?api_token=${fedtoken}`} style={{
                             height: 0,
                             width: 0,
                             visibility: "hidden"
                         }}
-                        />)}
+                        />;
+                    })}
             </div>;
         }
     });
