XThomasBU
commited on
Commit
·
02c7dd2
1
Parent(s):
c3cd73e
updates
Browse files- code/app.py +12 -6
- code/modules/config/constants.py +1 -0
code/app.py
CHANGED
@@ -8,13 +8,18 @@ from chainlit.utils import mount_chainlit
|
|
8 |
import secrets
|
9 |
import json
|
10 |
import base64
|
11 |
-
from modules.config.constants import
|
|
|
|
|
|
|
|
|
12 |
from fastapi.middleware.cors import CORSMiddleware
|
13 |
from fastapi.staticfiles import StaticFiles
|
|
|
14 |
|
15 |
GOOGLE_CLIENT_ID = OAUTH_GOOGLE_CLIENT_ID
|
16 |
GOOGLE_CLIENT_SECRET = OAUTH_GOOGLE_CLIENT_SECRET
|
17 |
-
GOOGLE_REDIRECT_URI = "
|
18 |
|
19 |
app = FastAPI()
|
20 |
app.mount("/public", StaticFiles(directory="public"), name="public")
|
@@ -49,8 +54,8 @@ flow = Flow.from_client_config(
|
|
49 |
"redirect_uris": [GOOGLE_REDIRECT_URI],
|
50 |
"scopes": [
|
51 |
"openid",
|
52 |
-
"https://www.googleapis.com/auth/userinfo.email",
|
53 |
-
"https://www.googleapis.com/auth/userinfo.profile",
|
54 |
],
|
55 |
}
|
56 |
},
|
@@ -173,7 +178,8 @@ async def post_signin(request: Request):
|
|
173 |
user_info = get_user_info_from_cookie(request)
|
174 |
if not user_info:
|
175 |
user_info = get_user_info(request)
|
176 |
-
if user_info and user_info.get("google_signed_in"):
|
|
|
177 |
username = user_info["email"]
|
178 |
role = get_user_role(username)
|
179 |
jwt_token = request.cookies.get("X-User-Info")
|
@@ -228,4 +234,4 @@ mount_chainlit(app=app, target="main.py", path=CHAINLIT_PATH)
|
|
228 |
if __name__ == "__main__":
|
229 |
import uvicorn
|
230 |
|
231 |
-
uvicorn.run(app, host="127.0.0.1", port=
|
|
|
8 |
import secrets
|
9 |
import json
|
10 |
import base64
|
11 |
+
from modules.config.constants import (
|
12 |
+
OAUTH_GOOGLE_CLIENT_ID,
|
13 |
+
OAUTH_GOOGLE_CLIENT_SECRET,
|
14 |
+
CHAINLIT_URL,
|
15 |
+
)
|
16 |
from fastapi.middleware.cors import CORSMiddleware
|
17 |
from fastapi.staticfiles import StaticFiles
|
18 |
+
import os
|
19 |
|
20 |
GOOGLE_CLIENT_ID = OAUTH_GOOGLE_CLIENT_ID
|
21 |
GOOGLE_CLIENT_SECRET = OAUTH_GOOGLE_CLIENT_SECRET
|
22 |
+
GOOGLE_REDIRECT_URI = f"{CHAINLIT_URL}/auth/oauth/google/callback"
|
23 |
|
24 |
app = FastAPI()
|
25 |
app.mount("/public", StaticFiles(directory="public"), name="public")
|
|
|
54 |
"redirect_uris": [GOOGLE_REDIRECT_URI],
|
55 |
"scopes": [
|
56 |
"openid",
|
57 |
+
# "https://www.googleapis.com/auth/userinfo.email",
|
58 |
+
# "https://www.googleapis.com/auth/userinfo.profile",
|
59 |
],
|
60 |
}
|
61 |
},
|
|
|
178 |
user_info = get_user_info_from_cookie(request)
|
179 |
if not user_info:
|
180 |
user_info = get_user_info(request)
|
181 |
+
# if user_info and user_info.get("google_signed_in"):
|
182 |
+
if user_info:
|
183 |
username = user_info["email"]
|
184 |
role = get_user_role(username)
|
185 |
jwt_token = request.cookies.get("X-User-Info")
|
|
|
234 |
if __name__ == "__main__":
|
235 |
import uvicorn
|
236 |
|
237 |
+
uvicorn.run(app, host="127.0.0.1", port=7860)
|
code/modules/config/constants.py
CHANGED
@@ -12,6 +12,7 @@ LLAMA_CLOUD_API_KEY = os.getenv("LLAMA_CLOUD_API_KEY")
|
|
12 |
HUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
|
13 |
LITERAL_API_KEY_LOGGING = os.getenv("LITERAL_API_KEY_LOGGING")
|
14 |
LITERAL_API_URL = os.getenv("LITERAL_API_URL")
|
|
|
15 |
|
16 |
OAUTH_GOOGLE_CLIENT_ID = os.getenv("OAUTH_GOOGLE_CLIENT_ID")
|
17 |
OAUTH_GOOGLE_CLIENT_SECRET = os.getenv("OAUTH_GOOGLE_CLIENT_SECRET")
|
|
|
12 |
HUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
|
13 |
LITERAL_API_KEY_LOGGING = os.getenv("LITERAL_API_KEY_LOGGING")
|
14 |
LITERAL_API_URL = os.getenv("LITERAL_API_URL")
|
15 |
+
CHAINLIT_URL = os.getenv("CHAINLIT_URL")
|
16 |
|
17 |
OAUTH_GOOGLE_CLIENT_ID = os.getenv("OAUTH_GOOGLE_CLIENT_ID")
|
18 |
OAUTH_GOOGLE_CLIENT_SECRET = os.getenv("OAUTH_GOOGLE_CLIENT_SECRET")
|