From 9053c58146e677390beaf2965c055e4a1dc24240 Mon Sep 17 00:00:00 2001 From: Liraz Yehezkel Date: Tue, 29 Mar 2022 10:25:25 +0300 Subject: [PATCH] Remove token from mizu community --- .../Pages/TrafficPage/TrafficPage.tsx | 4 ++-- ui/src/helpers/api.js | 24 ------------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/ui/src/components/Pages/TrafficPage/TrafficPage.tsx b/ui/src/components/Pages/TrafficPage/TrafficPage.tsx index 3b0419acf..4089ed578 100644 --- a/ui/src/components/Pages/TrafficPage/TrafficPage.tsx +++ b/ui/src/components/Pages/TrafficPage/TrafficPage.tsx @@ -1,6 +1,6 @@ import React, {useEffect, useState} from "react"; import { Button } from "@material-ui/core"; -import Api,{getWebsocketUrl} from "../../../helpers/api"; +import Api, { MizuWebsocketURL } from "../../../helpers/api"; import debounce from 'lodash/debounce'; import {useSetRecoilState, useRecoilState} from "recoil"; import {useCommonStyles} from "../../../helpers/commonStyle" @@ -65,7 +65,7 @@ const trafficViewerApi = {...api} return ( <> - ); diff --git a/ui/src/helpers/api.js b/ui/src/helpers/api.js index 229d8109b..1db29859f 100644 --- a/ui/src/helpers/api.js +++ b/ui/src/helpers/api.js @@ -3,13 +3,10 @@ import * as axios from "axios"; export const MizuWebsocketURL = process.env.REACT_APP_OVERRIDE_WS_URL ? process.env.REACT_APP_OVERRIDE_WS_URL : window.location.protocol === 'https:' ? `wss://${window.location.host}/ws` : `ws://${window.location.host}/ws`; -export const FormValidationErrorType = "formError"; - const CancelToken = axios.CancelToken; const apiURL = process.env.REACT_APP_OVERRIDE_API_URL ? process.env.REACT_APP_OVERRIDE_API_URL : `${window.location.origin}/`; -let token = "" let client = null let source = null @@ -24,8 +21,6 @@ export default class Api { } constructor() { - token = localStorage.getItem("token"); - client = this.getAxiosClient(); source = null; } @@ -125,20 +120,10 @@ export default class Api { return response.data; } - persistToken = (tk) => { - token = tk; - client = this.getAxiosClient(); - localStorage.setItem('token', token); - } - getAxiosClient = () => { const headers = { Accept: "application/json" } - - if (token) { - headers['x-session-token'] = `${token}`; // we use `x-session-token` instead of `Authorization` because the latter is reserved by kubectl proxy, making mizu view not work - } return axios.create({ baseURL: apiURL, timeout: 31000, @@ -146,12 +131,3 @@ export default class Api { }); } } - -export function getWebsocketUrl() { - let websocketUrl = MizuWebsocketURL; - if (token) { - websocketUrl += `/${token}`; - } - - return websocketUrl; -} \ No newline at end of file