Revert "Feat: Reforma de unificación de bases de datos."
This reverts commit 32cf2ba74a.
# Conflicts:
# Backend/MotoresArgentinosV2.API/Program.cs
This commit is contained in:
@@ -39,8 +39,6 @@ builder.Services.AddCors(options =>
|
||||
});
|
||||
|
||||
// FORWARDED HEADERS (CRÍTICO PARA DOCKER/NGINX)
|
||||
// Por defecto, .NET solo confía en localhost. En Docker, Nginx tiene otra IP.
|
||||
// Debemos limpiar las redes conocidas para que confíe en el proxy interno de Docker.
|
||||
builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
||||
{
|
||||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||
@@ -55,18 +53,15 @@ builder.Services.AddRateLimiter(options =>
|
||||
|
||||
options.GlobalLimiter = PartitionedRateLimiter.Create<HttpContext, string>(context =>
|
||||
{
|
||||
// En producción detrás de Nginx, RemoteIpAddress será la IP real del usuario.
|
||||
// Si por alguna razón falla (ej: conexión directa local), usamos "unknown".
|
||||
var remoteIp = context.Connection.RemoteIpAddress?.ToString() ?? "unknown";
|
||||
|
||||
// Si es Loopback (localhost), sin límites (útil para dev)
|
||||
if (System.Net.IPAddress.IsLoopback(context.Connection.RemoteIpAddress!))
|
||||
{
|
||||
return RateLimitPartition.GetNoLimiter("loopback");
|
||||
}
|
||||
|
||||
return RateLimitPartition.GetFixedWindowLimiter(
|
||||
partitionKey: remoteIp, // Clave correcta: IP del usuario
|
||||
partitionKey: remoteIp,
|
||||
factory: _ => new FixedWindowRateLimiterOptions
|
||||
{
|
||||
AutoReplenishment = true,
|
||||
@@ -78,7 +73,6 @@ builder.Services.AddRateLimiter(options =>
|
||||
|
||||
options.AddPolicy("AuthPolicy", context =>
|
||||
{
|
||||
// Si es localhost, SIN LÍMITES (Evita auto-bloqueo en desarrollo)
|
||||
var remoteIp = context.Connection.RemoteIpAddress;
|
||||
if (remoteIp != null && System.Net.IPAddress.IsLoopback(remoteIp))
|
||||
{
|
||||
@@ -100,9 +94,13 @@ builder.Services.Configure<HostOptions>(options =>
|
||||
options.BackgroundServiceExceptionBehavior = BackgroundServiceExceptionBehavior.Ignore;
|
||||
});
|
||||
|
||||
// DB CONTEXTS (Legacy unificado en eldia)
|
||||
// DB CONTEXTS
|
||||
builder.Services.AddDbContext<InternetDbContext>(options =>
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("Internet")));
|
||||
|
||||
builder.Services.AddDbContext<EldiaDbContext>(options =>
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("eldia")));
|
||||
|
||||
builder.Services.AddDbContext<MotoresV2DbContext>(options =>
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("MotoresV2"),
|
||||
sqlOptions => sqlOptions.EnableRetryOnFailure()));
|
||||
@@ -144,7 +142,6 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
{
|
||||
OnMessageReceived = context =>
|
||||
{
|
||||
// Buscar el token en la cookie llamada "accessToken"
|
||||
var accessToken = context.Request.Cookies["accessToken"];
|
||||
if (!string.IsNullOrEmpty(accessToken))
|
||||
{
|
||||
@@ -175,11 +172,7 @@ app.Use(async (context, next) =>
|
||||
context.Response.Headers.Append("X-Content-Type-Options", "nosniff");
|
||||
context.Response.Headers.Append("Referrer-Policy", "strict-origin-when-cross-origin");
|
||||
context.Response.Headers.Append("X-XSS-Protection", "1; mode=block");
|
||||
|
||||
// Permissions-Policy: Bloquear funcionalidades sensibles del navegador no usadas
|
||||
context.Response.Headers.Append("Permissions-Policy", "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()");
|
||||
|
||||
// CSP adaptada para permitir pagos en Payway y WebSockets de Vite
|
||||
string csp = "default-src 'self'; " +
|
||||
"img-src 'self' data: https: blob:; " +
|
||||
"script-src 'self' 'unsafe-inline'; " +
|
||||
@@ -190,7 +183,6 @@ app.Use(async (context, next) =>
|
||||
"form-action 'self' https://developers-ventasonline.payway.com.ar; " +
|
||||
"frame-ancestors 'none';";
|
||||
context.Response.Headers.Append("Content-Security-Policy", csp);
|
||||
|
||||
context.Response.Headers.Remove("Server");
|
||||
context.Response.Headers.Remove("X-Powered-By");
|
||||
await next();
|
||||
@@ -204,7 +196,6 @@ if (app.Environment.IsDevelopment())
|
||||
}
|
||||
else
|
||||
{
|
||||
// 🔒 HSTS en Producción
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user