Skip to content

Commit dfe2244

Browse files
feat: added flag based authentication using AUTH_ENABLED
1 parent d13d28d commit dfe2244

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/ContentProcessorWeb/.env

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
REACT_APP_API_BASE_URL=APP_API_BASE_URL
1+
REACT_APP_API_BASE_URL=https://ca-cps-d4ecoervb6ab-api.salmonbay-e4fea35b.eastus2.azurecontainerapps.io/
22

33
REACT_APP_WEB_CLIENT_ID = APP_WEB_CLIENT_ID
44
REACT_APP_WEB_AUTHORITY = APP_WEB_AUTHORITY
@@ -10,4 +10,6 @@ REACT_APP_POST_REDIRECT_URL = "/"
1010
REACT_APP_WEB_SCOPE = APP_WEB_SCOPE
1111

1212
REACT_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=false

src/ContentProcessorWeb/src/msal-auth/AuthWrapper.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ import useAuth from './useAuth';
1010
const AuthWrapper: React.FC<{ children: React.ReactNode }> = ({ children }) => {
1111

1212
const { isAuthenticated, login, inProgress,token } = useAuth();
13+
const authEnabled = process.env.REACT_APP_AUTH_ENABLED !== '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
};

0 commit comments

Comments
 (0)