Skip to content

Commit

Permalink
🐛 Only load keycloak when AUTH_REQUIRED is "true" (konveyor#1616)
Browse files Browse the repository at this point in the history
Only add the actual `AuthEnabledKeycloakProvider` keycloak handler if
the `AUTH_REQUIRED` environment variable is set `"true"`.

Signed-off-by: Scott J Dickerson <[email protected]>
  • Loading branch information
sjd78 authored Dec 13, 2023
1 parent eea7835 commit 712291c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions client/src/app/components/KeycloakProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ 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;
}

export const KeycloakProvider: React.FC<IKeycloakProviderProps> = ({
children,
}) => {
return ENV.AUTH_REQUIRED !== "true" ? (
<>{children}</>
) : (
<AuthEnabledKeycloakProvider>{children}</AuthEnabledKeycloakProvider>
);
};

const AuthEnabledKeycloakProvider: React.FC<IKeycloakProviderProps> = ({
children,
}) => {
React.useEffect(() => {
initInterceptors();
Expand Down

0 comments on commit 712291c

Please sign in to comment.