A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
fix(api): restrict CORS origins via ALLOWED_ORIGINS env
dextmorgnee06d6cf3e9a
diff --git a/.env.example b/.env.exampleindex cb62c8d9..2d6c1fe1 100644--- a/.env.example+++ b/.env.example@@ -6,5 +6,7 @@ NEO4J_URI_BOLT=bolt://neo4j:7687NEO4J_USERNAME=neo4jNEO4J_PASSWORD=passwordVITE_API_URL=http://127.0.0.1:5001+# Comma-separated CORS allowed origins. Defaults to http://localhost:5173 (Vite dev) when unset.+ALLOWED_ORIGINS=http://localhost:5173DATABASE_URL=postgresql://flowsint:flowsint@localhost:5433/flowsintREDIS_URL=redis://redis:6379/0diff --git a/flowsint-api/app/main.py b/flowsint-api/app/main.pyindex 60c99215..e45875fe 100644--- a/flowsint-api/app/main.py+++ b/flowsint-api/app/main.py@@ -1,3 +1,5 @@+import os+from fastapi import FastAPIfrom fastapi.middleware.cors import CORSMiddleware@@ -16,8 +18,12 @@ from app.api.routes import typesfrom app.api.routes import custom_typesfrom app.api.routes import enricher_templates+# Comma-separated list of allowed origins, e.g. "https://app.example.com,https://staging.example.com"+# Falls back to localhost dev origin when unset. Never use "*" with allow_credentials=True.origins = [- "*",+ o.strip()+ for o in os.getenv("ALLOWED_ORIGINS", "http://localhost:5173").split(",")+ if o.strip()]