File tree Expand file tree Collapse file tree 3 files changed +33
-22
lines changed Expand file tree Collapse file tree 3 files changed +33
-22
lines changed Original file line number Diff line number Diff line change 1- REACT_APP_API_BASE_URL = APP_API_BASE_URL
1+ REACT_APP_API_BASE_URL = APP_API_BASE_URL
22
33REACT_APP_WEB_CLIENT_ID = APP_WEB_CLIENT_ID
44REACT_APP_WEB_AUTHORITY = APP_WEB_AUTHORITY
@@ -10,4 +10,6 @@ REACT_APP_POST_REDIRECT_URL = "/"
1010REACT_APP_WEB_SCOPE = APP_WEB_SCOPE
1111
1212REACT_APP_API_SCOPE = APP_API_SCOPE
13- REACT_APP_CONSOLE_LOG_ENABLED = APP_CONSOLE_LOG_ENABLED
13+ REACT_APP_CONSOLE_LOG_ENABLED = APP_CONSOLE_LOG_ENABLED
14+
15+ REACT_APP_AUTH_ENABLED = APP_AUTH_ENABLED
Original file line number Diff line number Diff line change @@ -57,6 +57,8 @@ const HeaderPage: React.FC<HeaderPageProps> = ({ toggleTheme, isDarkMode }) => {
5757 const { shortcutLabel } = useHeaderHooks ( { toggleTheme, isDarkMode } ) ;
5858 const { user, logout, getToken } = useAuth ( ) ;
5959
60+ const authEnabled = process . env . REACT_APP_AUTH_ENABLED ?. toLowerCase ( ) !== 'false' ; // Defaults to true if not set
61+
6062 const { openSwaggerUI } = useSwaggerPreview ( ) ;
6163 const store = useSelector ( ( state : RootState ) => ( {
6264 swaggerJSON : state . leftPanel . swaggerJSON ,
@@ -126,24 +128,26 @@ const HeaderPage: React.FC<HeaderPageProps> = ({ toggleTheme, isDarkMode }) => {
126128 </ div >
127129
128130 { /* Tools Section */ }
129- < div className = "headerTools" >
130- < Menu hasIcons positioning = { { autoSize : true } } >
131- < MenuTrigger disableButtonEnhancement >
132- < Avatar
133- color = "colorful"
134- name = { user ?. name }
135- aria-label = "App"
136- className = "clickable-avatar"
137- />
138- </ MenuTrigger >
139- < MenuPopover style = { { minWidth : "192px" } } >
140- < MenuList >
141- < MenuDivider />
142- < MenuItem icon = { < ArrowExit /> } onClick = { logout } > Logout</ MenuItem >
143- </ MenuList >
144- </ MenuPopover >
145- </ Menu >
146- </ div >
131+ { authEnabled &&
132+ < div className = "headerTools" >
133+ < Menu hasIcons positioning = { { autoSize : true } } >
134+ < MenuTrigger disableButtonEnhancement >
135+ < Avatar
136+ color = "colorful"
137+ name = { user ?. name }
138+ aria-label = "App"
139+ className = "clickable-avatar"
140+ />
141+ </ MenuTrigger >
142+ < MenuPopover style = { { minWidth : "192px" } } >
143+ < MenuList >
144+ < MenuDivider />
145+ < MenuItem icon = { < ArrowExit /> } onClick = { logout } > Logout</ MenuItem >
146+ </ MenuList >
147+ </ MenuPopover >
148+ </ Menu >
149+ </ div >
150+ }
147151 </ Header >
148152 ) ;
149153} ;
Original file line number Diff line number Diff line change @@ -10,12 +10,17 @@ import useAuth from './useAuth';
1010const AuthWrapper : React . FC < { children : React . ReactNode } > = ( { children } ) => {
1111
1212 const { isAuthenticated, login, inProgress, token } = useAuth ( ) ;
13+ const authEnabled = process . env . REACT_APP_AUTH_ENABLED ?. toLowerCase ( ) !== 'false' ; // Defaults to true if not set
1314
1415 useEffect ( ( ) => {
15- if ( ! isAuthenticated && inProgress === InteractionStatus . None ) {
16+ if ( authEnabled && ! isAuthenticated && inProgress === InteractionStatus . None ) {
1617 login ( ) ;
1718 }
18- } , [ isAuthenticated , inProgress ] ) ;
19+ } , [ authEnabled , isAuthenticated , inProgress ] ) ;
20+
21+ if ( ! authEnabled ) {
22+ return < > { children } </ > ;
23+ }
1924
2025 return < > { ( isAuthenticated && token ) && children } </ >
2126} ;
You can’t perform that action at this time.
0 commit comments