fix: review issues - enforce IsAuthenticated for API, secure CORS via env vars

This commit is contained in:
Marko (Hermes Implementer)
2026-05-26 06:06:16 +00:00
parent 811045daca
commit 22d36cb7df
2 changed files with 14 additions and 5 deletions
+10 -2
View File
@@ -90,12 +90,20 @@ USE_TZ = True
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
# CORS
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_ALL_ORIGINS = os.environ.get("CORS_ALLOW_ALL_ORIGINS", "False").lower() in ("true", "1", "yes")
CORS_ALLOWED_ORIGINS = os.environ.get(
"CORS_ALLOWED_ORIGINS",
"http://localhost:3000,http://localhost:5173,http://127.0.0.1:3000",
).split(",")
# REST Framework
REST_FRAMEWORK = {
"DEFAULT_PERMISSION_CLASSES": [
"rest_framework.permissions.AllowAny",
"rest_framework.permissions.IsAuthenticated",
],
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework_simplejwt.authentication.JWTAuthentication",
"rest_framework.authentication.SessionAuthentication",
],
}