fix: require production database connection environment
This commit is contained in:
@@ -204,12 +204,15 @@ jobs:
|
|||||||
echo "ERROR: QuantEngine.Web.dll not found"
|
echo "ERROR: QuantEngine.Web.dll not found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$DEPLOY_DIR/appsettings.Production.json" ]; then
|
echo "✓ DLL verified"
|
||||||
echo "ERROR: appsettings.Production.json not found"
|
# Production connection settings must come from the service
|
||||||
|
# EnvironmentFile, never from a versioned appsettings file.
|
||||||
|
SERVICE_ENV=$(sudo systemctl show "$SERVICE_NAME" -p EnvironmentFiles --value 2>/dev/null || true)
|
||||||
|
if [ -z "$SERVICE_ENV" ]; then
|
||||||
|
echo "ERROR: $SERVICE_NAME has no EnvironmentFile; database credentials are not configured"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "✓ DLL verified"
|
echo "✓ External service environment configured"
|
||||||
echo "✓ Config verified"
|
|
||||||
|
|
||||||
# 3. Update Symlink
|
# 3. Update Symlink
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -81,6 +81,12 @@ try
|
|||||||
// PostgreSQL Dapper Setup
|
// PostgreSQL Dapper Setup
|
||||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
|
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
|
||||||
?? throw new InvalidOperationException("Connection string 'DefaultConnection' is required.");
|
?? throw new InvalidOperationException("Connection string 'DefaultConnection' is required.");
|
||||||
|
if (builder.Environment.IsProduction()
|
||||||
|
&& string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("ConnectionStrings__DefaultConnection")))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"Production requires ConnectionStrings__DefaultConnection from the service environment.");
|
||||||
|
}
|
||||||
|
|
||||||
var configuredDatabase = new NpgsqlConnectionStringBuilder(connectionString).Database;
|
var configuredDatabase = new NpgsqlConnectionStringBuilder(connectionString).Database;
|
||||||
if (!string.Equals(configuredDatabase, "quantenginedb", StringComparison.OrdinalIgnoreCase))
|
if (!string.Equals(configuredDatabase, "quantenginedb", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": "Host=127.0.0.1;Database=quantenginedb;Username=quantengine_app;Password=quantengine_app;Search Path=quantengine;"
|
"DefaultConnection": "Host=127.0.0.1;Database=quantenginedb;Username=quantengine_app;Search Path=quantengine;"
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"AdminSettings": {
|
"AdminSettings": {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": "Host=127.0.0.1;Database=quantenginedb;Username=quantengine_app;Password=quantengine_app;Search Path=quantengine;"
|
"DefaultConnection": "Host=127.0.0.1;Database=quantenginedb;Username=quantengine_app;Search Path=quantengine;"
|
||||||
},
|
},
|
||||||
"AdminSettings": {
|
"AdminSettings": {
|
||||||
"Username": "admin",
|
"Username": "admin",
|
||||||
|
|||||||
Reference in New Issue
Block a user