Skip to content

Commit 69a58f0

Browse files
committed
feat: safety on simulation route, on database name
1 parent 9942e5b commit 69a58f0

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

src/sum_impact_assessment/api/routes/simulation.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ def check_non_production_environment():
2828
Raises:
2929
HTTPException: 403 Forbidden if ENV is 'production'
3030
"""
31-
if settings.ENV.lower() == "production":
32-
logger.warning(
33-
"Attempted to access simulation endpoint in production environment",
34-
extra={"env": settings.ENV}
35-
)
36-
raise HTTPException(
37-
status_code=status.HTTP_403_FORBIDDEN,
38-
detail="Simulation endpoints are not available in production environment"
39-
)
40-
return True
31+
if settings.ENV.lower() != "production" and settings.DB_NAME != "sumodp":
32+
return True
33+
logger.warning(
34+
"Attempted to access simulation endpoint in production environment",
35+
extra={"env": settings.ENV}
36+
)
37+
raise HTTPException(
38+
status_code=status.HTTP_403_FORBIDDEN,
39+
detail="Simulation endpoints are not available in production environment"
40+
)
4141

4242

4343
class SimulateKPIResultsRequest(BaseModel):
@@ -238,6 +238,7 @@ def get_environment_status():
238238

239239
return {
240240
"environment": settings.ENV,
241+
"db_name": settings.DB_NAME,
241242
"simulation_endpoints_enabled": not is_production,
242243
"message": "Simulation endpoints disabled" if is_production else "Simulation endpoints enabled"
243244
}

0 commit comments

Comments
 (0)