Files
localesp/openspec/changes/hide-admin-route/proposal.md
T
edgar.friendly 85a054d886
deploy-branch / deploy (push) Failing after 3m7s
deploy-branch / teardown (push) Skipped
tests / Unitarias + componente + build (push) Failing after 3m17s
tests / Integración (Nominatim real, opt-in) (push) Skipped
tests / Unitarias + componente + build (pull_request) Failing after 3m10s
tests / Integración (Nominatim real, opt-in) (pull_request) Skipped
feat(seguridad): rutas admin bajo prefijo configurable obligatorio
Cambio openspec hide-admin-route: las rutas de administración se montan
bajo LOCALESP_ADMIN_PREFIX (única variable, obligatoria, sin valor por
defecto) y las rutas históricas /api/... dejan de existir (404 natural).

- server: autocarga de .env (sin pisar el entorno) y fail-fast claro si
  falta LOCALESP_ADMIN_PREFIX; reportar/confirmar siguen públicas
- frontend: src/api.js usa el prefijo expuesto por Vite (envPrefix);
  npm run build falla sin la variable; proxy de dev la lee vía loadEnv
- .env.example como template único de configuración
- tests: 109/109 en verde (rutas bajo prefijo, 404s históricos y
  fail-fast sin configurar)
- openspec: artefactos del cambio sincronizados (design/spec/tasks)
2026-10-02 21:57:02 +02:00

26 lines
1.3 KiB
Markdown

# Hide Admin Route
## Why
The `/api/pendientes` endpoint (admin-only) and `/api/reportes` endpoint are currently exposed at obvious routes, making them easy targets for attackers. By default, the admin panel URL is well-known or discoverable via route enumeration (`/admin`, `/admin/api/pendientes`, `/api/pendientes`). This increases the attack surface of the application.
By obscuring or moving the admin route, we increase the effort required for attackers to find the admin panel, reducing the likelihood of unwanted access.
## What Changes
- **New capability**: `route-obfuscation` — middleware-based approach to hide the admin API routes by redirecting access attempts and serving a 404 or custom page.
- Modify server configuration to intercept requests to known admin API routes and return a 404 or redirect to a custom page.
## Capabilities
### New Capabilities
- **route-obfuscation**: Protects admin routes (`/api/pendientes`, `/api/reportes`, `/api/locales/:id/*`) by returning a 404 response when accessed without authentication, without exposing the route listing in response to global route enumeration.
## Impact
- Affects the server configuration in `server/index.js`.
- Adds middleware to filter/admin route protection.
- Does not change the API contract for authenticated users.
- No database changes required.