diff --git a/backend/oasst_backend/api/v1/api.py b/backend/oasst_backend/api/v1/api.py index 2931ac05..003f039f 100644 --- a/backend/oasst_backend/api/v1/api.py +++ b/backend/oasst_backend/api/v1/api.py @@ -1,6 +1,7 @@ from fastapi import APIRouter from oasst_backend.api.v1 import ( admin, + auth, frontend_messages, frontend_users, hugging_face, @@ -23,3 +24,4 @@ api_router.include_router(stats.router, prefix="/stats", tags=["stats"]) api_router.include_router(leaderboards.router, prefix="/leaderboards", tags=["leaderboards"]) api_router.include_router(hugging_face.router, prefix="/hf", tags=["hugging_face"]) api_router.include_router(admin.router, prefix="/admin", tags=["admin"]) +api_router.include_router(auth.router, prefix="/auth", tags=["auth"]) diff --git a/backend/requirements.txt b/backend/requirements.txt index 0f91315e..dff8d14c 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -6,7 +6,9 @@ loguru==0.6.0 numpy==1.22.4 psycopg2-binary==2.9.5 pydantic==1.9.1 +pyjwt python-dotenv==0.21.0 +redis scipy==1.8.1 SQLAlchemy==1.4.41 sqlmodel==0.0.8 diff --git a/docker-compose.yaml b/docker-compose.yaml index 908457cd..60048763 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -4,7 +4,7 @@ services: # Use `docker compose up backend-dev --build --attach-dependencies` to start a database and work and the backend. backend-dev: image: sverrirab/sleep - depends_on: [db, adminer, redis, redis-insights] + depends_on: [db, adminer, redis, redis-insights, webdb, maildev] # Use `docker compose up frontend-dev --build --attach-dependencies` to start all services needed to work on the frontend. frontend-dev: diff --git a/scripts/backend-development/run-local.sh b/scripts/backend-development/run-local.sh index 7366cde6..f81362dd 100755 --- a/scripts/backend-development/run-local.sh +++ b/scripts/backend-development/run-local.sh @@ -8,6 +8,7 @@ export DEBUG_USE_SEED_DATA=True export DEBUG_SKIP_TOXICITY_CALCULATION=True export DEBUG_ALLOW_SELF_LABELING=True export DEBUG_SKIP_EMBEDDING_COMPUTATION=True +export BACKEND_CORS_ORIGINS='["http://localhost:3000"]' uvicorn main:app --reload --port 8080 --host 0.0.0.0 diff --git a/website/src/pages/api/auth/[...nextauth].ts b/website/src/pages/api/auth/[...nextauth].ts index 3d3dbaa4..af2cbd59 100644 --- a/website/src/pages/api/auth/[...nextauth].ts +++ b/website/src/pages/api/auth/[...nextauth].ts @@ -148,6 +148,17 @@ export const authOptions: AuthOptions = { } }, }, + cookies: { + sessionToken: { + name: `next-auth.session-token`, + options: { + httpOnly: true, + sameSite: "none", + path: "/", + secure: true, + }, + }, + }, session: { strategy: "jwt", }, diff --git a/website/src/pages/dashboard.tsx b/website/src/pages/dashboard.tsx index e0b8bba4..2739821b 100644 --- a/website/src/pages/dashboard.tsx +++ b/website/src/pages/dashboard.tsx @@ -7,9 +7,12 @@ import { TaskCategory } from "src/components/Tasks/TaskTypes"; import { get } from "src/lib/api"; import type { AvailableTasks, TaskType } from "src/types/Task"; export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props"; +import useSWR from "swr"; import useSWRImmutable from "swr/immutable"; const Dashboard = () => { + useSWR("http://localhost:8080/api/v1/auth/check", get); + const { data } = useSWRImmutable("/api/available_tasks", get); // TODO: show only these tasks: