From 9795108a0bc947fe471dfe8ea30df0f4c3b43710 Mon Sep 17 00:00:00 2001 From: Scott J Dickerson Date: Wed, 13 Dec 2023 11:26:36 -0500 Subject: [PATCH] :bug: Only load keycloak when `AUTH_REQUIRED` is "true" Only add the actual `AuthEnabledKeycloakProvider` keycloak handler if the `AUTH_REQUIRED` environment variable is set `"true"`. Signed-off-by: Scott J Dickerson --- client/src/app/components/KeycloakProvider.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client/src/app/components/KeycloakProvider.tsx b/client/src/app/components/KeycloakProvider.tsx index 363be14fed..4ba2211b6b 100644 --- a/client/src/app/components/KeycloakProvider.tsx +++ b/client/src/app/components/KeycloakProvider.tsx @@ -3,6 +3,7 @@ import { ReactKeycloakProvider } from "@react-keycloak/web"; import keycloak from "@app/keycloak"; import { AppPlaceholder } from "./AppPlaceholder"; import { initInterceptors } from "@app/axios-config"; +import ENV from "@app/env"; interface IKeycloakProviderProps { children: React.ReactNode; @@ -10,6 +11,16 @@ interface IKeycloakProviderProps { export const KeycloakProvider: React.FC = ({ children, +}) => { + return ENV.AUTH_REQUIRED !== "true" ? ( + <>{children} + ) : ( + {children} + ); +}; + +const AuthEnabledKeycloakProvider: React.FC = ({ + children, }) => { React.useEffect(() => { initInterceptors();