Skip to content

Commit 2b230e3

Browse files
Feature toggle for authentication
1 parent 123a6bd commit 2b230e3

File tree

8 files changed

+21
-6
lines changed

8 files changed

+21
-6
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ Allow unauthenticated request : Yes
149149
| VITE_GOOGLE_CLIENT_ID | Optional | | Client ID for Google authentication |
150150
| VITE_LLM_MODELS_PROD | Optional | openai_gpt_4o,openai_gpt_4o_mini,diffbot,gemini_1.5_flash | To Distinguish models based on the Enviornment PROD or DEV
151151
| VITE_LLM_MODELS | Optional | 'diffbot,openai_gpt_3.5,openai_gpt_4o,openai_gpt_4o_mini,gemini_1.5_pro,gemini_1.5_flash,azure_ai_gpt_35,azure_ai_gpt_4o,ollama_llama3,groq_llama3_70b,anthropic_claude_3_5_sonnet' | Supported Models For the application
152+
| VITE_AUTH0_CLIENT_ID | Mandatory if you are enabling Authentication otherwise it is optional | |Okta Oauth Client ID for authentication
153+
| VITE_AUTH0_DOMAIN | Mandatory if you are enabling Authentication otherwise it is optional | | Okta Oauth Cliend Domain
154+
| VITE_SKIP_AUTH | Optional | true | Flag to skip the authentication
152155

153156
## LLMs Supported
154157
1. OpenAI

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ services:
6565
- VITE_LLM_MODELS_PROD=${VITE_LLM_MODELS_PROD-openai_gpt_4o,openai_gpt_4o_mini,diffbot,gemini_1.5_flash}
6666
- VITE_AUTH0_DOMAIN=${VITE_AUTH0_DOMAIN-}
6767
- VITE_AUTH0_CLIENT_ID=${VITE_AUTH0_CLIENT_ID-}
68+
- VITE_SKIP_AUTH=$VITE_SKIP_AUTH-true}
6869
- DEPLOYMENT_ENV=local
6970
volumes:
7071
- ./frontend:/app

frontend/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ARG VITE_BATCH_SIZE=2
1515
ARG VITE_LLM_MODELS_PROD="openai_gpt_4o,openai_gpt_4o_mini,diffbot,gemini_1.5_flash"
1616
ARG VITE_AUTH0_CLIENT_ID=""
1717
ARG VITE_AUTH0_DOMAIN=""
18+
ARG VITE_SKIP_AUTH="false"
1819

1920
WORKDIR /app
2021
COPY package.json yarn.lock ./
@@ -34,6 +35,7 @@ RUN VITE_BACKEND_API_URL=$VITE_BACKEND_API_URL \
3435
VITE_LLM_MODELS_PROD=$VITE_LLM_MODELS_PROD \
3536
VITE_AUTH0_CLIENT_ID=$VITE_AUTH0_CLIENT_ID \
3637
VITE_AUTH0_DOMAIN=$VITE_AUTH0_DOMAIN \
38+
VITE_SKIP_AUTH=$VITE_SKIP_AUTH \
3739
yarn run build
3840

3941
# Step 2: Serve the application using Nginx

frontend/example.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ VITE_LLM_MODELS_PROD="openai_gpt_4o,openai_gpt_4o_mini,diffbot,gemini_1.5_flash"
1313
VITE_FRONTEND_HOSTNAME="localhost:8080"
1414
VITE_SEGMENT_API_URL=""
1515
VITE_AUTH0_CLIENT_ID=""
16-
VITE_AUTH0_DOMAIN=""
16+
VITE_AUTH0_DOMAIN=""
17+
VITE_SKIP_AUTH=true

frontend/src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { Route, Routes } from 'react-router-dom';
22
import ChatOnlyComponent from './components/ChatBot/ChatOnlyComponent';
33
import { AuthenticationGuard } from './components/Auth/Auth';
44
import Home from './Home';
5+
import { SKIP_AUTH } from './utils/Constants.ts';
6+
57
const App = () => {
68
return (
79
<Routes>
8-
<Route path='/' element={<AuthenticationGuard component={Home} />}></Route>
10+
<Route path='/' element={SKIP_AUTH ? <Home /> : <AuthenticationGuard component={Home} />}></Route>
911
<Route path='/chat-only' element={<ChatOnlyComponent />}></Route>
1012
</Routes>
1113
);

frontend/src/components/Layout/Header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { Button, TextLink, Typography } from '@neo4j-ndl/react';
1414
import { Dispatch, memo, SetStateAction, useCallback, useContext, useRef, useState } from 'react';
1515
import { IconButtonWithToolTip } from '../UI/IconButtonToolTip';
16-
import { buttonCaptions, tooltips } from '../../utils/Constants';
16+
import { buttonCaptions, SKIP_AUTH, tooltips } from '../../utils/Constants';
1717
import { ThemeWrapperContext } from '../../context/ThemeWrapper';
1818
import { useCredentials } from '../../context/UserCredentials';
1919
import { useNavigate } from 'react-router';
@@ -144,7 +144,7 @@ const Header: React.FC<HeaderProp> = ({ chatOnly, deleteOnClick, setOpenConnecti
144144
>
145145
<ArrowTopRightOnSquareIconOutline />
146146
</IconButtonWithToolTip>
147-
<Profile />
147+
{!SKIP_AUTH && <Profile />}
148148
</div>
149149
</div>
150150
</section>

frontend/src/main.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ import { BrowserRouter } from 'react-router-dom';
44
import Auth0ProviderWithHistory from './components/Auth/Auth.tsx';
55
import React from 'react';
66
import App from './App.tsx';
7+
import { SKIP_AUTH } from './utils/Constants.ts';
78

89
ReactDOM.createRoot(document.getElementById('root')!).render(
910
<React.StrictMode>
1011
<BrowserRouter>
11-
<Auth0ProviderWithHistory>
12+
{SKIP_AUTH ? (
1213
<App />
13-
</Auth0ProviderWithHistory>
14+
) : (
15+
<Auth0ProviderWithHistory>
16+
<App />
17+
</Auth0ProviderWithHistory>
18+
)}
1419
</BrowserRouter>
1520
</React.StrictMode>
1621
);

frontend/src/utils/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,4 @@ export const metricsinfo: Record<string, string> = {
382382
context_entity_recall: 'Determines the recall of entities present in both generated answer and retrieved contexts',
383383
};
384384
export const EXPIRATION_DAYS = 3;
385+
export const SKIP_AUTH = (process.env.VITE_SKIP_AUTH ?? 'true') == 'true';

0 commit comments

Comments
 (0)