cambios profundos

This commit is contained in:
2026-06-20 20:01:40 +02:00
parent 2f5f37c7b4
commit 98fd85226b
21 changed files with 158 additions and 118 deletions
+24
View File
@@ -4,6 +4,7 @@ import (
"embed"
"flag"
"fmt"
"io"
"io/fs"
"log"
"net/http"
@@ -37,6 +38,29 @@ func main() {
}
eaProxy := httputil.NewSingleHostReverseProxy(eaURL)
// Evita que el navegador muestre el popup de credenciales.
// Nunca exponemos WWW-Authenticate ni mensajes de auth del backend.
eaProxy.ModifyResponse = func(resp *http.Response) error {
resp.Header.Del("Www-Authenticate")
// Evitamos que cookies de sesión de EA lleguen al navegador del usuario público
resp.Header.Del("Set-Cookie")
// Limpiamos cabeceras que revelan el backend
resp.Header.Del("Server")
resp.Header.Del("X-Powered-By")
if resp.StatusCode == http.StatusUnauthorized || resp.StatusCode == http.StatusForbidden {
resp.StatusCode = http.StatusBadGateway
resp.Status = http.StatusText(http.StatusBadGateway)
// Reemplazamos el body para no filtrar detalles del backend
resp.Body.Close()
resp.Body = io.NopCloser(strings.NewReader(`{"error": "service_unavailable"}`))
resp.ContentLength = -1
resp.Header.Set("Content-Type", "application/json")
resp.Header.Del("Content-Length")
}
return nil
}
http.HandleFunc("/ea-api/", func(w http.ResponseWriter, r *http.Request) {
// /ea-api/v1/services → /index.php/api/v1/services
r.URL.Path = strings.Replace(r.URL.Path, "/ea-api", "/index.php/api", 1)