Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Admin routes are public and that is load-bearing

Abierto
#514 3 comentarios 0 reacciones 0 asignados Ver en GitHub

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

area:security difficulty:easy help wanted points:100
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 the ADMIN_TOKEN check 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 /admin is 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() is lens_ plus randomBytes(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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Divinity-Labs/Lens

Todos los issues de Divinity-Labs/Lens

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.