Admin routes are public and that is load-bearing
Los mantenedores suelen responder en 1 día
@sparkysolutions10-pixel ya está trabajando en esto.
Desde el 19/10/2026.
- #574 de @sparkysolutions10-pixel — abierto
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 58/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
Línea de trabajo
Start by reading src/api/auth.ts and src/api/admin.ts to understand the existing API-key hook and admin-token checks; then inspect src/tests/auth.test.ts and run it with npx vitest run src/tests/auth.test.ts. Update the route protection and configuration, and add coverage that checks every registered /admin/* route rejects unauthenticated requests while genuinely public routes remain unaffected.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Background
Every admin route is registered with config: { public: true }:
app.post<{ Body: CreateKeyBody }>(
'/admin/keys',
{ config: { public: true } },
...
It does not mean the route is public. It means "skip the API-key auth hook",
because these routes enforce ADMIN_TOKEN themselves — a key-minting endpoint
cannot require a key.
The trap is that public: true is also what genuinely public routes use, so
the same flag means two things, and the admin routes' real protection lives
further down the handler in a function that is easy to not notice — and that
exists in two copies (L232).
A route added to admin.ts by copying a neighbour inherits public: true and
is protected only if its author remembers the manual check.
What to build
- Make the admin surface's protection structural rather than per-handler: a
separate plugin or scope where theADMIN_TOKENcheck runs as a hook for
every route inside it, so a new route is guarded by being in the right place. - Distinguish "no auth" from "admin auth" in the route config, so reading a
route definition tells the truth about who can call it. - A test that enumerates registered routes and asserts every
/admin/*path
requires admin authorisation — the test that catches the route somebody adds
next year.
Acceptance criteria
- Admin routes are guarded by a hook, not by a call inside each handler
- Route config distinguishes genuinely public routes from admin-guarded ones
- A new route under
/adminis protected by default - A test asserts every registered
/admin/*route rejects an unauthenticated request - Genuinely public routes are unaffected
Drips Wave · Complexity: Easy · 100 points
Repo: Divinity-Labs/Lens. Auth is src/api/auth.ts, key minting
src/api/admin.ts, usage reporting src/api/usage.ts, metering
src/x402/metering.ts, the ApiKey model in prisma/schema.prisma.
Run the tests: npm test. The tests are vitest, not jest. A single file
is npx vitest run src/__tests__/auth.test.ts.
Load test (prices) is already failing on main. Not your PR.
Do not weaken what is already right. Three things are correct today and
should survive every change here:
generateApiKey()islens_plusrandomBytes(24)— 192 bits. Do not
shorten it, and do not make it guessable or sequential.hashApiKey()is an unsalted SHA-256. That is correct for a
high-entropy random key: it must stay fast and deterministic so a lookup is
one indexed query. Do not "improve" it into bcrypt or argon2 — those are for
low-entropy human passwords, and here they would only make every request slow.- Only the hash is ever stored. The plaintext is returned once, at creation,
and never again.
Admin routes carry config: { public: true }. That does not mean public —
it means "skip the API-key hook", because they enforce ADMIN_TOKEN instead.
Removing that flag locks the admin surface behind the keys it exists to mint.
Never elide an address, a key or a token in code, comments, tests or
documentation. Write it in full or not at all — and never write a real key
anywhere.
Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk
- Lenguaje dominante
- TypeScript
- Estrellas
- 4
- Forks
- 71
- Merge medio
- 1 d 11 h
- PR fusionados (30 d)
- 64
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Divinity-Labs/Lens
-
Webhook retries have no jitter, so failures synchronisePosiblemente ocupada @Richard-tobi la tomó hace 5 días. Abiertoarea:reliability difficulty:easy help wanted points:100 Stellar Wave
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
Divinity-Labs/Lens#341 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
SSRF guard re-resolves DNS at connect time, so rebinding is still possiblePosiblemente ocupada @sparkysolutions10-pixel la tomó hace 2 días. Abiertoarea:security help wanted
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Divinity-Labs/Lens#515 ·
Los mantenedores suelen responder en 1 día
-
A caller cannot see their own usagePosiblemente ocupada @sparkysolutions10-pixel la tomó hace 2 días. Abiertoarea:api-quality difficulty:intermediate help wanted points:150
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Divinity-Labs/Lens#513 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
The key is accepted only as a bearer token, and nothing says soPosiblemente ocupada @krsnak la tomó hace 3 días. Abiertoarea:docs difficulty:easy help wanted points:100 Stellar Wave
Divinity-Labs/Lens#512 · 4 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
The admin surface has no testsPosiblemente ocupada @krsnak la tomó hace 3 días. Abiertoarea:testing difficulty:intermediate help wanted points:150 Stellar Wave
Divinity-Labs/Lens#510 · 5 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de Divinity-Labs/Lens
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
endora-commerce/endora-commerce#397 ·
Los mantenedores suelen responder en 1 día
-
level/task
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
wazuh/wazuh-dashboard-plugins#9472 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
Los mantenedores suelen responder en 1 día
-
ready-for-agent
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
xavxyz/bei-shan-lin-shui#57 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
opennextjs/opennextjs-cloudflare#1461 ·
Los mantenedores suelen responder en 1 día