From ee3ec96e1241b4cc3afe99da3d9ea86bb784dc5f Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 31 Jan 2022 18:27:57 -0300 Subject: [PATCH] 17914: Fixes regression introduced in ticket 17568. Ticket 17568 fixed a token expiration display issue. Still, it introduced a problem on peer federations because the code attempts to use the salted token to query the home cluster, which isn't an authorized operation. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- src/store/auth/auth-action.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/store/auth/auth-action.ts b/src/store/auth/auth-action.ts index c7074704..d58a8103 100644 --- a/src/store/auth/auth-action.ts +++ b/src/store/auth/auth-action.ts @@ -86,9 +86,15 @@ export const saveApiToken = (token: string) => async (dispatch: Dispatch, getSta const auth = getState().auth; config = dispatch(getConfig); - // If federated token, get user & token data from the token issuing cluster - if (tokenParts.length === 3 && tokenParts[1].substring(0, 5) !== auth.localCluster) { - config = await getRemoteHostConfig(auth.remoteHosts[tokenParts[1].substring(0, 5)]); + // If the token is from a LoginCluster federation, get user & token data + // from the token issuing cluster. + const lc = (config as Config).loginCluster + const tokenCluster = tokenParts.length === 3 + ? tokenParts[1].substring(0, 5) + : undefined; + if (tokenCluster && tokenCluster !== auth.localCluster && + lc && lc === tokenCluster) { + config = await getRemoteHostConfig(auth.remoteHosts[tokenCluster]); } const svc = createServices(config, { progressFn: () => { }, errorFn: () => { } }); -- 2.30.2