This commit is contained in:
parent
a4135228f1
commit
06ac295e17
|
@ -6,3 +6,5 @@ pydantic-settings
|
||||||
s3fs
|
s3fs
|
||||||
aiofiles
|
aiofiles
|
||||||
duckdb
|
duckdb
|
||||||
|
pyjwt[crypto]
|
||||||
|
python-multipart
|
|
@ -30,12 +30,16 @@ certifi==2024.2.2
|
||||||
# httpcore
|
# httpcore
|
||||||
# httpx
|
# httpx
|
||||||
# requests
|
# requests
|
||||||
|
cffi==1.16.0
|
||||||
|
# via cryptography
|
||||||
charset-normalizer==3.3.2
|
charset-normalizer==3.3.2
|
||||||
# via requests
|
# via requests
|
||||||
click==8.1.7
|
click==8.1.7
|
||||||
# via
|
# via
|
||||||
# typer
|
# typer
|
||||||
# uvicorn
|
# uvicorn
|
||||||
|
cryptography==42.0.7
|
||||||
|
# via pyjwt
|
||||||
dataclasses-json==0.6.6
|
dataclasses-json==0.6.6
|
||||||
# via langchain-community
|
# via langchain-community
|
||||||
distro==1.9.0
|
distro==1.9.0
|
||||||
|
@ -123,6 +127,8 @@ packaging==23.2
|
||||||
# via
|
# via
|
||||||
# langchain-core
|
# langchain-core
|
||||||
# marshmallow
|
# marshmallow
|
||||||
|
pycparser==2.22
|
||||||
|
# via cffi
|
||||||
pydantic==2.7.1
|
pydantic==2.7.1
|
||||||
# via
|
# via
|
||||||
# fastapi
|
# fastapi
|
||||||
|
@ -136,6 +142,7 @@ pydantic-core==2.18.2
|
||||||
pydantic-settings==2.2.1
|
pydantic-settings==2.2.1
|
||||||
pygments==2.18.0
|
pygments==2.18.0
|
||||||
# via rich
|
# via rich
|
||||||
|
pyjwt==2.8.0
|
||||||
python-dateutil==2.9.0.post0
|
python-dateutil==2.9.0.post0
|
||||||
# via botocore
|
# via botocore
|
||||||
python-dotenv==1.0.1
|
python-dotenv==1.0.1
|
||||||
|
|
|
@ -6,6 +6,7 @@ class Settings(BaseSettings):
|
||||||
gcs_access: str = "access"
|
gcs_access: str = "access"
|
||||||
gcs_secret: str = "secret"
|
gcs_secret: str = "secret"
|
||||||
gcs_bucketname: str = "bucket"
|
gcs_bucketname: str = "bucket"
|
||||||
|
auth: bool = False
|
||||||
|
|
||||||
model_config = SettingsConfigDict(env_file=".env")
|
model_config = SettingsConfigDict(env_file=".env")
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,24 @@
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
from typing import Annotated
|
||||||
from fastapi import APIRouter
|
from fastapi import APIRouter, Depends
|
||||||
from fastapi.responses import PlainTextResponse
|
from fastapi.responses import PlainTextResponse
|
||||||
|
|
||||||
|
from ..config import settings
|
||||||
|
from ..security import oauth2_scheme
|
||||||
|
# Scheme for the Authorization header
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
|
if settings.auth:
|
||||||
|
|
||||||
|
@router.get("/token")
|
||||||
|
async def get_token() -> str:
|
||||||
|
return str(uuid4())
|
||||||
|
|
||||||
|
|
||||||
@router.get("/new_session")
|
@router.get("/new_session")
|
||||||
async def get_new_session() -> str:
|
async def get_new_session(token: Annotated[str, Depends(oauth2_scheme)]) -> str:
|
||||||
return str(uuid4())
|
return str(uuid4())
|
||||||
|
|
||||||
|
|
||||||
|
|
3
src/hellocomputer/security.py
Normal file
3
src/hellocomputer/security.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from fastapi.security import OAuth2PasswordBearer
|
||||||
|
|
||||||
|
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|
Loading…
Reference in a new issue