Files
localesp/openspec/changes/archive/2026-01-11-hide-admin-route/specs/route-obfuscation/spec.md
T
edgar.friendly d34ebf7ca0
deploy-branch / deploy (push) Successful in 3m11s
deploy-branch / teardown (push) Skipped
tests / Unitarias + componente + build (push) Failing after 3m27s
tests / Integración (Nominatim real, opt-in) (push) Skipped
tests / Unitarias + componente + build (pull_request) Failing after 3m0s
tests / Integración (Nominatim real, opt-in) (pull_request) Skipped
feat(pasarela): campo opcional de descripción en la pasarela de proponer local
Nueva pantalla "Descripción" (paso 5 de 6, opcional, máx. 200 caracteres)
entre Tipo específico y Revisión. La descripción viaja en la propuesta
(trim; vacía → ausente/NULL), el filtro de palabras prohibidas la cubre y
el resumen la muestra. Backend/BD ya la soportaban: cambio frontend-only.

Incluye el archivo del cambio hide-admin-route y la propuesta
openspec del nuevo cambio. Suite: 114/114.
2026-10-11 15:04:37 +02:00

91 lines
3.9 KiB
Markdown

# Route Obfuscation Spec
## Description
The route obfuscation capability mounts all admin-only API routes under a
configurable prefix (`LOCALESP_ADMIN_PREFIX`). The well-known `/api/...` admin
paths no longer have handlers and return 404, hiding the admin surface from
route enumeration without adding authentication.
## ADDED Requirements
### Requirement: Admin routes are served only under a configurable prefix
The system SHALL serve admin-only endpoints exclusively under the value of
`LOCALESP_ADMIN_PREFIX` (**required, no default**: the server fails fast with
a clear error when it is unset; documented in `.env.example`, which the
server auto-loads without overriding real environment variables), and SHALL
NOT register handlers for those endpoints under the legacy `/api` paths.
Admin endpoints under the prefix:
| Endpoint | Method |
|---|---|
| `$ADMIN_PREFIX/pendientes` | GET |
| `$ADMIN_PREFIX/aprobar/:id` | POST |
| `$ADMIN_PREFIX/rechazar/:id` | POST |
| `$ADMIN_PREFIX/locales/:id` | DELETE |
| `$ADMIN_PREFIX/reportes` | GET |
| `$ADMIN_PREFIX/reportes/:id/descartar` | POST |
#### Scenario: Legacy admin path returns 404 when a prefix is configured
- **WHEN** `LOCALESP_ADMIN_PREFIX` is set to a value other than `/api`
- **AND** a client makes a request to `/api/pendientes`, `/api/reportes`,
`/api/aprobar/:id`, `/api/rechazar/:id`, `DELETE /api/locales/:id` or
`/api/reportes/:id/descartar`
- **THEN** the server responds with HTTP 404
- **AND** no data is returned and no action is executed
#### Scenario: Prefixed admin path serves data to clients that know it
- **WHEN** `LOCALESP_ADMIN_PREFIX` is set to a value other than `/api`
- **AND** a client requests `$ADMIN_PREFIX/pendientes`
- **THEN** the server responds with the pending proposals as before
- **AND** the admin panel works unchanged because the frontend is compiled
with the same single `LOCALESP_ADMIN_PREFIX` variable
(exposed to the client via Vite `envPrefix`)
#### Scenario: Missing configuration fails fast
- **WHEN** `LOCALESP_ADMIN_PREFIX` is not set (or empty)
- **THEN** the server refuses to start with a clear configuration error
- **AND** there is no default value: every deployment must choose its prefix
(documented in `.env.example`)
#### Scenario: Public routes are unaffected
- **WHEN** a client makes a GET request to `/api/locales`
- **THEN** the server responds with HTTP 200 and the list of locales
#### Scenario: User-facing report and confirm actions remain public
- **WHEN** a client makes a POST request to `/api/locales/:id/reportar` or
`/api/locales/:id/confirmar`
- **THEN** the endpoints behave as before, because the public website uses
them (they are user features, not admin surface)
## REMOVED Requirements
### Requirement: Admin panel routes are fully discoverable
**Reason**: Security concern — admin routes should be harder to discover
**Migration**: Admin users access the panel at the prefix root
(`$ADMIN_PREFIX`, compiled with the same `LOCALESP_ADMIN_PREFIX`); its API
calls go to the configured prefix
## MODIFIED Requirements
### Requirement: Admin panel serves pending proposals
The requirement SHALL:
1. Allow unauthenticated clients to submit proposals via `/api/propuestas` (unchanged)
2. Serve the pending-proposals list from `$ADMIN_PREFIX/pendientes` (legacy
`/api/pendientes` returns 404 when a prefix is configured)
#### Scenario: Admin views pending proposals through the panel
- **WHEN** an admin opens the panel at the prefix root (`$ADMIN_PREFIX`,
e.g. `/administrador`)
- **THEN** the panel fetches `$ADMIN_PREFIX/pendientes` (compiled with
`LOCALESP_ADMIN_PREFIX`) and renders the list exactly as before
- **AND** the legacy `/admin` URL renders the public site (the panel route
no longer exists)
**Design note**: This is obscurity, not security: the prefix ships in the
frontend bundle. It raises the cost of blind route enumeration only. Real
authentication is explicitly deferred to a future change.