feat: optional auth

pull/12/head
Cullen Watson 2023-08-19 20:31:10 -05:00
parent aeb2b34618
commit 4144562053
2 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,11 @@
from fastapi import APIRouter, Depends from fastapi import APIRouter, Depends
from .jobs import router as jobs_router from .jobs import router as jobs_router
from api.auth.auth_utils import get_active_current_user from api.auth.auth_utils import get_active_current_user
from settings import AUTH_REQUIRED
if AUTH_REQUIRED:
router = APIRouter(prefix="/v1", dependencies=[Depends(get_active_current_user)]) router = APIRouter(prefix="/v1", dependencies=[Depends(get_active_current_user)])
else:
router = APIRouter(prefix="/v1")
router.include_router(jobs_router) router.include_router(jobs_router)

View File

@ -7,3 +7,4 @@ SUPABASE_KEY = os.environ.get("SUPABASE_KEY")
JWT_SECRET_KEY = os.environ.get("JWT_SECRET_KEY") JWT_SECRET_KEY = os.environ.get("JWT_SECRET_KEY")
ALGORITHM = "HS256" ALGORITHM = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES = 60 ACCESS_TOKEN_EXPIRE_MINUTES = 60
AUTH_REQUIRED = False