Files
localesp/openspec/changes/hide-admin-route/specs/route-obfuscation/spec.md
T
edgar.friendly 4d7d9e19dc
deploy-branch / deploy (push) Successful in 2m59s
deploy-branch / teardown (push) Skipped
tests / Unitarias + componente + build (push) Failing after 3m30s
tests / Integración (Nominatim real, opt-in) (push) Skipped
tests / Unitarias + componente + build (pull_request) Failing after 3m25s
tests / Integración (Nominatim real, opt-in) (pull_request) Skipped
feat(panel): el panel admin vive en la raíz del prefijo, /admin desaparece
La ruta fija /admin del enrutador SPA mostraba el panel sin importar el
prefijo configurado. Ahora AdminPanel se monta solo cuando el pathname
coincide con la raíz de LOCALESP_ADMIN_PREFIX (misma variable única que
backend, build y API): con /administrador, el panel queda en
/administrador y /admin pasa a mostrar la web pública.

- src/main.jsx: enrutado por ADMIN_RUTA derivada del prefijo
- README y artefactos openspec (spec/design) actualizados
2026-10-03 14:33:34 +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.