Skip to content

Commit

Permalink
Updated health dashboard endpoint configuration to use API GW instanc…
Browse files Browse the repository at this point in the history
…e of health API endpoint. Also fixed how cookies are read.
  • Loading branch information
anilnatha committed Sep 16, 2024
1 parent 9a3a496 commit fe7c8ed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 128 deletions.
121 changes: 0 additions & 121 deletions public/data/health.json

This file was deleted.

20 changes: 14 additions & 6 deletions src/AuthorizationWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@ import App from './App';

import { useCookies } from 'react-cookie';

let token:string;
let email:string;
let username:string;

export const GetUsername = () => {
const [cookies] = useCookies(['oidc_claim_username']);
return cookies['oidc_claim_username'];
return username;
};

export const GetEmail = () => {
const [cookies] = useCookies(['oidc_claim_email']);
return cookies['oidc_claim_email'];
return email;
};

export const GetToken = () => {
const [cookies] = useCookies(['oidc_access_token']);
return cookies['oidc_access_token'];
return token;
};

const AuthorizationWrapper = () => {

const [cookies] = useCookies(["oidc_access_token", "oidc_claim_username", "oidc_claim_email"]);

token = cookies.oidc_access_token;
username = cookies.oidc_claim_username;
email = cookies.oidc_claim_email;

return (
<CookiesProvider>
<Provider store={store}>
Expand Down
6 changes: 5 additions & 1 deletion src/state/slices/healthSlice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios, { AxiosRequestConfig } from 'axios';
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
import Config from "../../Config";
import { GetToken } from '../../AuthorizationWrapper';

enum HEALTH_ACTIONS {
GET_HEALTH = "health/getHealth",
Expand Down Expand Up @@ -39,13 +40,16 @@ export const getHealthData = createAsyncThunk(
async (_:void, thunkAPI) => {

const url = Config['cs']['health_endpoint'];
const token = GetToken();

const config:AxiosRequestConfig = {
headers: {
"Content-Type": "application/json"
"Content-Type": "application/json",
"Authorization": "Bearer " + token
}
}


try {
const response = await axios.get(url, config);
return response.data.services;
Expand Down

0 comments on commit fe7c8ed

Please sign in to comment.