diff --git a/ui/src/api/api.tsx b/ui/src/api/api.tsx index b6eb12a75..167bd05ee 100644 --- a/ui/src/api/api.tsx +++ b/ui/src/api/api.tsx @@ -212,11 +212,25 @@ export const getIdToken = async ( export const authAxios = async (msalInstance: PublicClientApplication) => { const token = await getIdToken(msalInstance); - return Axios.create({ + const axios = Axios.create({ headers: { Authorization: "Bearer " + token, "Content-Type": "application/json", }, baseURL: getApiBaseUrl(), }); + + axios.interceptors.response.use( + (response) => { + return response; + }, + (error) => { + if (error.response?.status === 403) { + const detail = error.response.data.detail; + window.location.href = "/responseErrors/403/" + detail; + } + //TODO: handle other response errors + } + ); + return axios; }; diff --git a/ui/src/app.tsx b/ui/src/app.tsx index d79960859..66a09574a 100644 --- a/ui/src/app.tsx +++ b/ui/src/app.tsx @@ -14,6 +14,7 @@ import Jobs from "./pages/jobs/jobs"; import Monitoring from "./pages/monitoring/monitoring"; import LineageGraph from "./pages/feature/lineageGraph"; import Management from "./pages/management/management"; +import ResponseErrors from "./pages/responseErrors/responseErrors"; import RoleManagement from "./pages/management/roleManagement"; import { getMsalConfig } from "./utils/utils"; @@ -46,6 +47,10 @@ const App: React.FC = () => { } /> } /> } /> + } + /> diff --git a/ui/src/pages/responseErrors/responseErrors.tsx b/ui/src/pages/responseErrors/responseErrors.tsx new file mode 100644 index 000000000..57197dca4 --- /dev/null +++ b/ui/src/pages/responseErrors/responseErrors.tsx @@ -0,0 +1,31 @@ +import { Card, Typography } from "antd"; +import { useParams } from "react-router-dom"; + +const { Title } = Typography; + +const ResponseErrors: React.FC = () => { + const { status, detail } = useParams(); + switch (status) { + case "403": + return ( +
+ + ERROR 403 + ACCESS NOT GRANTED + {detail} + +
+ ); + + default: + return ( +
+ + Unknown Error + +
+ ); + } +}; + +export default ResponseErrors;