Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
SESSION_COOKIE_NAME = os.getenv("SESSION_COOKIE_NAME", "behaviorai_session")
SESSION_DURATION_DAYS = int(os.getenv("SESSION_DURATION_DAYS", "7"))
SESSION_COOKIE_SECURE = os.getenv("SESSION_COOKIE_SECURE", "false").lower() == "true"
SESSION_COOKIE_SAMESITE = os.getenv("SESSION_COOKIE_SAMESITE", "lax").lower()
MIN_PASSWORD_LENGTH = int(os.getenv("MIN_PASSWORD_LENGTH", "12"))
MAX_BCRYPT_BYTES = 72

Expand Down Expand Up @@ -95,12 +96,17 @@ def set_session_cookie(response: Response, session_id: str, max_age_seconds: int
value=session_id,
httponly=True,
max_age=max_age_seconds,
samesite="lax",
samesite=SESSION_COOKIE_SAMESITE,
secure=SESSION_COOKIE_SECURE,
)

def clear_session_cookie(response: Response) -> None:
response.delete_cookie(key=SESSION_COOKIE_NAME)
response.delete_cookie(
key=SESSION_COOKIE_NAME,
httponly=True,
samesite=SESSION_COOKIE_SAMESITE,
secure=SESSION_COOKIE_SECURE,
)
@app.get("/")
async def root():
return {"status": "Backend is running", "api_docs": "/docs"}
Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ services:
dockerfile: Dockerfile.dev
#survives vm reboots, otherwise port 8000 silently drops
restart: unless-stopped
#loopback only: caddy terminates tls and proxies to this, so the port must
#not be reachable from the internet. docker's nat bypasses iptables INPUT,
#so binding to 127.0.0.1 is what actually keeps it private.
ports:
- "8000:8000"
- "127.0.0.1:8000:8000"
volumes:
- ./backend:/app
env_file:
Expand Down
Loading