16159: Passes the token to be expire when calling the logout endpoint.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 31 Mar 2021 14:31:56 +0000 (11:31 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Wed, 31 Mar 2021 14:31:56 +0000 (11:31 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/services/auth-service/auth-service.ts
src/store/auth/auth-middleware.test.ts
src/store/auth/auth-middleware.ts

index 8d27b5bbe88991a255c56fe92db6461965133c25..bd4bc1969c5004d1506f39b3d5a233d748d2fa57 100644 (file)
@@ -103,9 +103,9 @@ export class AuthService {
         window.location.assign(`https://${homeClusterHost}/login?${(uuidPrefix !== homeCluster && homeCluster !== loginCluster) ? "remote=" + uuidPrefix + "&" : ""}return_to=${currentUrl}`);
     }
 
-    public logout() {
+    public logout(expireToken: string) {
         const currentUrl = `${window.location.protocol}//${window.location.host}`;
-        window.location.assign(`${this.baseUrl || ""}/logout?return_to=${currentUrl}`);
+        window.location.assign(`${this.baseUrl || ""}/logout?api_token=${expireToken}&return_to=${currentUrl}`);
     }
 
     public getUserDetails = (showErrors?: boolean): Promise<User> => {
index bcc942e1ee76e85f338ed34bc2db80437715d1ef..1438cab35a121bb9f7f63668a1c1d31906afd864 100644 (file)
@@ -38,7 +38,7 @@ describe("AuthMiddleware", () => {
         const middleware = authMiddleware(services)(store)(next);
         middleware(authActions.LOGOUT({deleteLinkData: false}));
         expect(window.location.assign).toBeCalledWith(
-            `/logout?return_to=${location.protocol}//${location.host}`
+            `/logout?api_token=someToken&return_to=${location.protocol}//${location.host}`
         );
         expect(localStorage.getItem(API_TOKEN_KEY)).toBeFalsy();
     });
index 6eef5e5e16a59cd74d826dc3c32a09b6215894c4..ce7cd5cb6f9ceebd165af5b6ea275d56dc5aa871 100644 (file)
@@ -64,11 +64,12 @@ export const authMiddleware = (services: ServiceRepository): Middleware => store
             if (deleteLinkData) {
                 services.linkAccountService.removeAccountToLink();
             }
+            const token = services.authService.getApiToken();
             services.authService.removeApiToken();
             services.authService.removeSessions();
             services.authService.removeUser();
             removeAuthorizationHeader(services);
-            services.authService.logout();
+            services.authService.logout(token || '');
         },
         default: () => next(action)
     });