X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/3b53b656e65fdabc32b3bc748074eb35e9df98eb..fc73adaad544e07a970f720fd1fec3d30821d4b1:/src/views/workbench/fed-login.tsx

diff --git a/src/views/workbench/fed-login.tsx b/src/views/workbench/fed-login.tsx
index 399b419e..7c8b87c7 100644
--- a/src/views/workbench/fed-login.tsx
+++ b/src/views/workbench/fed-login.tsx
@@ -5,7 +5,6 @@
 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';
@@ -13,7 +12,7 @@ import { Config } from '~/common/config';
 export interface FedLoginProps {
     user?: User;
     apiToken?: string;
-    homeCluster: string;
+    localCluster: string;
     remoteHostsConfig: { [key: string]: Config };
 }
 
@@ -21,26 +20,35 @@ const mapStateToProps = ({ auth }: RootState) => ({
     user: auth.user,
     apiToken: auth.apiToken,
     remoteHostsConfig: auth.remoteHostsConfig,
-    homeCluster: auth.homeCluster,
+    localCluster: auth.localCluster,
 });
 
 export const FedLogin = connect(mapStateToProps)(
     class extends React.Component<FedLoginProps> {
         render() {
-            const { apiToken, user, homeCluster, remoteHostsConfig } = this.props;
-            if (!apiToken || !user || !user.uuid.startsWith(homeCluster)) {
+            const { apiToken, user, localCluster, remoteHostsConfig } = this.props;
+            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 !== homeCluster &&
-                        <iframe key={k} src={`${remoteHostsConfig[k].workbench2Url}/fedtoken?api_token=${getSaltedToken(k, tokenUuid, token)}`} style={{
+                    .map((k) => {
+                        if (k === localCluster) {
+                            return;
+                        }
+                        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;
+                        }
+                        const fedtoken = (remoteHostsConfig[k].loginCluster === localCluster)
+                            ? apiToken : getSaltedToken(k, apiToken);
+                        return <iframe key={k} src={`${remoteHostsConfig[k].workbench2Url}/fedtoken?api_token=${fedtoken}`} style={{
                             height: 0,
                             width: 0,
                             visibility: "hidden"
                         }}
-                        />)}
+                        />;
+                    })}
             </div>;
         }
     });
