mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-29 15:37:05 +00:00
Hotfix: [FE] Remove user token from websocket
Hotfix: Remove token from mizu community #patch Merge pull request #947 from up9inc/hotfix/Remove_token_from_community
This commit is contained in:
commit
4a0294c61a
@ -1,6 +1,6 @@
|
|||||||
import React, {useEffect, useState} from "react";
|
import React, {useEffect, useState} from "react";
|
||||||
import { Button } from "@material-ui/core";
|
import { Button } from "@material-ui/core";
|
||||||
import Api,{getWebsocketUrl} from "../../../helpers/api";
|
import Api, { MizuWebsocketURL } from "../../../helpers/api";
|
||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
import {useSetRecoilState, useRecoilState} from "recoil";
|
import {useSetRecoilState, useRecoilState} from "recoil";
|
||||||
import {useCommonStyles} from "../../../helpers/commonStyle"
|
import {useCommonStyles} from "../../../helpers/commonStyle"
|
||||||
@ -65,7 +65,7 @@ const trafficViewerApi = {...api}
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TrafficViewer setAnalyzeStatus={setAnalyzeStatus} webSocketUrl={getWebsocketUrl()} isCloseWebSocket={!openWebSocket}
|
<TrafficViewer setAnalyzeStatus={setAnalyzeStatus} webSocketUrl={MizuWebsocketURL} isCloseWebSocket={!openWebSocket}
|
||||||
trafficViewerApiProp={trafficViewerApi} actionButtons={actionButtons} isShowStatusBar={!openOasModal} isDemoBannerView={false}/>
|
trafficViewerApiProp={trafficViewerApi} actionButtons={actionButtons} isShowStatusBar={!openOasModal} isDemoBannerView={false}/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -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 :
|
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`;
|
window.location.protocol === 'https:' ? `wss://${window.location.host}/ws` : `ws://${window.location.host}/ws`;
|
||||||
|
|
||||||
export const FormValidationErrorType = "formError";
|
|
||||||
|
|
||||||
const CancelToken = axios.CancelToken;
|
const CancelToken = axios.CancelToken;
|
||||||
|
|
||||||
const apiURL = process.env.REACT_APP_OVERRIDE_API_URL ? process.env.REACT_APP_OVERRIDE_API_URL : `${window.location.origin}/`;
|
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 client = null
|
||||||
let source = null
|
let source = null
|
||||||
|
|
||||||
@ -24,8 +21,6 @@ export default class Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
token = localStorage.getItem("token");
|
|
||||||
|
|
||||||
client = this.getAxiosClient();
|
client = this.getAxiosClient();
|
||||||
source = null;
|
source = null;
|
||||||
}
|
}
|
||||||
@ -125,20 +120,10 @@ export default class Api {
|
|||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
persistToken = (tk) => {
|
|
||||||
token = tk;
|
|
||||||
client = this.getAxiosClient();
|
|
||||||
localStorage.setItem('token', token);
|
|
||||||
}
|
|
||||||
|
|
||||||
getAxiosClient = () => {
|
getAxiosClient = () => {
|
||||||
const headers = {
|
const headers = {
|
||||||
Accept: "application/json"
|
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({
|
return axios.create({
|
||||||
baseURL: apiURL,
|
baseURL: apiURL,
|
||||||
timeout: 31000,
|
timeout: 31000,
|
||||||
@ -146,12 +131,3 @@ export default class Api {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getWebsocketUrl() {
|
|
||||||
let websocketUrl = MizuWebsocketURL;
|
|
||||||
if (token) {
|
|
||||||
websocketUrl += `/${token}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return websocketUrl;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user