[ARVADOS-WORKBENCH2] updated: 1.1.4-442-gcba00ea

Git user git at public.curoverse.com
Fri Aug 3 01:32:26 EDT 2018


Summary of changes:
 src/common/api/server-api.ts              | 19 -------------------
 src/services/auth-service/auth-service.ts |  8 ++++----
 src/services/services.ts                  |  7 +------
 src/store/auth/auth-action.ts             | 18 ++++++++++++++----
 src/store/auth/auth-reducer.ts            |  1 -
 5 files changed, 19 insertions(+), 34 deletions(-)
 delete mode 100644 src/common/api/server-api.ts

       via  cba00eaa2d205b13cfa696f866a31452c6511cf3 (commit)
      from  27f903d5e3aa7f1c936808d0a7be37a70283516f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit cba00eaa2d205b13cfa696f866a31452c6511cf3
Author: Daniel Kos <daniel.kos at contractors.roche.com>
Date:   Fri Aug 3 07:32:19 2018 +0200

    Remove auth client
    
    Feature #13901
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos at contractors.roche.com>

diff --git a/src/common/api/server-api.ts b/src/common/api/server-api.ts
deleted file mode 100644
index a700f27..0000000
--- a/src/common/api/server-api.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import { AxiosInstance } from "axios";
-
-export function setServerApiAuthorizationHeader(clients: AxiosInstance[], token: string) {
-    clients.forEach(client => {
-        client.defaults.headers.common = {
-            Authorization: `OAuth2 ${token}`
-        };
-    });
-}
-
-export function removeServerApiAuthorizationHeader(clients: AxiosInstance[]) {
-    clients.forEach(client => {
-        delete client.defaults.headers.common.Authorization;
-    });
-}
diff --git a/src/services/auth-service/auth-service.ts b/src/services/auth-service/auth-service.ts
index 273208c..f96edc7 100644
--- a/src/services/auth-service/auth-service.ts
+++ b/src/services/auth-service/auth-service.ts
@@ -24,8 +24,8 @@ export interface UserDetailsResponse {
 export class AuthService {
 
     constructor(
-        protected authClient: AxiosInstance,
-        protected apiClient: AxiosInstance) { }
+        protected apiClient: AxiosInstance,
+        protected baseUrl: string) { }
 
     public saveApiToken(token: string) {
         localStorage.setItem(API_TOKEN_KEY, token);
@@ -77,12 +77,12 @@ export class AuthService {
 
     public login() {
         const currentUrl = `${window.location.protocol}//${window.location.host}/token`;
-        window.location.assign(`${this.authClient.defaults.baseURL || ""}/login?return_to=${currentUrl}`);
+        window.location.assign(`${this.baseUrl || ""}/login?return_to=${currentUrl}`);
     }
 
     public logout() {
         const currentUrl = `${window.location.protocol}//${window.location.host}`;
-        window.location.assign(`${this.authClient.defaults.baseURL || ""}/logout?return_to=${currentUrl}`);
+        window.location.assign(`${this.baseUrl || ""}/logout?return_to=${currentUrl}`);
     }
 
     public getUserDetails = (): Promise<User> => {
diff --git a/src/services/services.ts b/src/services/services.ts
index 0d19cee..e137176 100644
--- a/src/services/services.ts
+++ b/src/services/services.ts
@@ -15,7 +15,6 @@ import Axios from "axios";
 
 export interface ServiceRepository {
     apiClient: AxiosInstance;
-    authClient: AxiosInstance;
 
     authService: AuthService;
     groupsService: GroupsService;
@@ -26,13 +25,10 @@ export interface ServiceRepository {
 }
 
 export const createServices = (baseUrl: string): ServiceRepository => {
-    const authClient = Axios.create();
     const apiClient = Axios.create();
-
-    authClient.defaults.baseURL = baseUrl;
     apiClient.defaults.baseURL = `${baseUrl}/arvados/v1`;
 
-    const authService = new AuthService(authClient, apiClient);
+    const authService = new AuthService(apiClient, baseUrl);
     const groupsService = new GroupsService(apiClient);
     const projectService = new ProjectService(apiClient);
     const linkService = new LinkService(apiClient);
@@ -41,7 +37,6 @@ export const createServices = (baseUrl: string): ServiceRepository => {
 
     return {
         apiClient,
-        authClient,
         authService,
         groupsService,
         projectService,
diff --git a/src/store/auth/auth-action.ts b/src/store/auth/auth-action.ts
index 839134c..6b81c31 100644
--- a/src/store/auth/auth-action.ts
+++ b/src/store/auth/auth-action.ts
@@ -7,7 +7,7 @@ import { Dispatch } from "redux";
 import { User } from "../../models/user";
 import { RootState } from "../store";
 import { ServiceRepository } from "../../services/services";
-import { removeServerApiAuthorizationHeader, setServerApiAuthorizationHeader } from "../../common/api/server-api";
+import { AxiosInstance } from "axios";
 
 export const authActions = unionize({
     SAVE_API_TOKEN: ofType<string>(),
@@ -21,11 +21,21 @@ export const authActions = unionize({
     value: 'payload'
 });
 
+function setAuthorizationHeader(client: AxiosInstance, token: string) {
+    client.defaults.headers.common = {
+        Authorization: `OAuth2 ${token}`
+    };
+}
+
+function removeAuthorizationHeader(client: AxiosInstance) {
+    delete client.defaults.headers.common.Authorization;
+}
+
 export const initAuth = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
     const user = services.authService.getUser();
     const token = services.authService.getApiToken();
     if (token) {
-        setServerApiAuthorizationHeader([services.authClient, services.apiClient], token);
+        setAuthorizationHeader(services.apiClient, token);
     }
     if (token && user) {
         dispatch(authActions.INIT({ user, token }));
@@ -34,7 +44,7 @@ export const initAuth = () => (dispatch: Dispatch, getState: () => RootState, se
 
 export const saveApiToken = (token: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
     services.authService.saveApiToken(token);
-    setServerApiAuthorizationHeader([services.authClient, services.apiClient], token);
+    setAuthorizationHeader(services.apiClient, token);
     dispatch(authActions.SAVE_API_TOKEN(token));
 };
 
@@ -46,7 +56,7 @@ export const login = () => (dispatch: Dispatch, getState: () => RootState, servi
 export const logout = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
     services.authService.removeApiToken();
     services.authService.removeUser();
-    removeServerApiAuthorizationHeader([services.authClient, services.apiClient]);
+    removeAuthorizationHeader(services.apiClient);
     services.authService.logout();
     dispatch(authActions.LOGOUT());
 };
diff --git a/src/store/auth/auth-reducer.ts b/src/store/auth/auth-reducer.ts
index ac9ecbe..1546212 100644
--- a/src/store/auth/auth-reducer.ts
+++ b/src/store/auth/auth-reducer.ts
@@ -5,7 +5,6 @@
 import { authActions, AuthAction } from "./auth-action";
 import { User } from "../../models/user";
 import { ServiceRepository } from "../../services/services";
-import { removeServerApiAuthorizationHeader, setServerApiAuthorizationHeader } from "../../common/api/server-api";
 
 export interface AuthState {
     user?: User;

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list