Skip to content

Commit 30fa154

Browse files
authored
Merge pull request #3 from fdciabdul/main
fix: align JWT secret default, correct frontend backend URL, validate…
2 parents e4837fb + ada44ab commit 30fa154

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

backend/routes/webhooks.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
from typing import Any
3+
from urllib.parse import urlparse
34

45
import httpx
56
from fastapi import APIRouter, Depends, HTTPException
@@ -37,9 +38,14 @@ async def create_webhook(data: dict[str, Any], current_user: User = Depends(get_
3738
if current_user.role not in ("admin", "instructor"):
3839
raise HTTPException(status_code=403, detail="Insufficient permissions")
3940

41+
url = data.get("url", "")
42+
parsed = urlparse(url)
43+
if parsed.scheme not in ("http", "https") or not parsed.netloc:
44+
raise HTTPException(status_code=400, detail="Webhook URL must be http(s) with a host")
45+
4046
webhook = WebhookConfig(
4147
name=data["name"],
42-
url=data["url"],
48+
url=url,
4349
events=data.get("events", ["simulation_complete"]),
4450
secret=data.get("secret"),
4551
organization_id=current_user.organization_id,

backend/services/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from models.schemas import User
1010
from services.database import db
1111

12-
JWT_SECRET = os.environ.get("JWT_SECRET", "soceng-lab-secret-key-change-in-production")
12+
JWT_SECRET = os.environ.get("JWT_SECRET", "change-this-secret-key-in-production")
1313
JWT_ALGORITHM = "HS256"
1414
JWT_EXPIRATION_HOURS = 24
1515

frontend/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# REACT_APP_BACKEND_URL
2-
REACT_APP_BACKEND_URL="http://localhost:8001"
2+
REACT_APP_BACKEND_URL="http://localhost:9442"

0 commit comments

Comments
 (0)