diff --git a/src/ContentProcessorWeb/.env b/src/ContentProcessorWeb/.env index ecf8f866..8b85deed 100644 --- a/src/ContentProcessorWeb/.env +++ b/src/ContentProcessorWeb/.env @@ -1,4 +1,4 @@ -REACT_APP_API_BASE_URL=APP_API_BASE_URL +REACT_APP_API_BASE_URL = APP_API_BASE_URL REACT_APP_WEB_CLIENT_ID = APP_WEB_CLIENT_ID REACT_APP_WEB_AUTHORITY = APP_WEB_AUTHORITY @@ -10,4 +10,6 @@ REACT_APP_POST_REDIRECT_URL = "/" REACT_APP_WEB_SCOPE = APP_WEB_SCOPE REACT_APP_API_SCOPE = APP_API_SCOPE -REACT_APP_CONSOLE_LOG_ENABLED = APP_CONSOLE_LOG_ENABLED \ No newline at end of file +REACT_APP_CONSOLE_LOG_ENABLED = APP_CONSOLE_LOG_ENABLED + +REACT_APP_AUTH_ENABLED = APP_AUTH_ENABLED \ No newline at end of file diff --git a/src/ContentProcessorWeb/src/Components/Header/Header.tsx b/src/ContentProcessorWeb/src/Components/Header/Header.tsx index 2e4cce41..5abbbe2d 100644 --- a/src/ContentProcessorWeb/src/Components/Header/Header.tsx +++ b/src/ContentProcessorWeb/src/Components/Header/Header.tsx @@ -57,6 +57,8 @@ const HeaderPage: React.FC = ({ toggleTheme, isDarkMode }) => { const { shortcutLabel } = useHeaderHooks({ toggleTheme, isDarkMode }); const { user, logout, getToken } = useAuth(); + const authEnabled = process.env.REACT_APP_AUTH_ENABLED?.toLowerCase() !== 'false'; // Defaults to true if not set + const { openSwaggerUI } = useSwaggerPreview(); const store = useSelector((state: RootState) => ({ swaggerJSON: state.leftPanel.swaggerJSON, @@ -126,24 +128,26 @@ const HeaderPage: React.FC = ({ toggleTheme, isDarkMode }) => { {/* Tools Section */} -
- - - - - - - - } onClick={logout}>Logout - - - -
+ { authEnabled && +
+ + + + + + + + } onClick={logout}>Logout + + + +
+ } ); }; diff --git a/src/ContentProcessorWeb/src/msal-auth/AuthWrapper.tsx b/src/ContentProcessorWeb/src/msal-auth/AuthWrapper.tsx index bfbae666..6df2d600 100644 --- a/src/ContentProcessorWeb/src/msal-auth/AuthWrapper.tsx +++ b/src/ContentProcessorWeb/src/msal-auth/AuthWrapper.tsx @@ -10,12 +10,17 @@ import useAuth from './useAuth'; const AuthWrapper: React.FC<{ children: React.ReactNode }> = ({ children }) => { const { isAuthenticated, login, inProgress,token } = useAuth(); + const authEnabled = process.env.REACT_APP_AUTH_ENABLED?.toLowerCase() !== 'false'; // Defaults to true if not set useEffect(() => { - if (!isAuthenticated && inProgress === InteractionStatus.None) { + if (authEnabled && !isAuthenticated && inProgress === InteractionStatus.None) { login(); } - }, [isAuthenticated, inProgress]); + }, [authEnabled, isAuthenticated, inProgress]); + + if (!authEnabled) { + return <>{children}; + } return <>{(isAuthenticated && token) && children} };