Files
netris-nestri/apps/auth/wrangler.jsonc
Wanjohi f30a1432f8 fix(deploy): require every credential, and give sandbox its own domain
Three things review caught, and one shape correction.

**No credential has a default any more.** The compose file shipped
`ADMIN_SHARED_SECRET` falling back to a value written in this repository —
and that header bypasses token verification entirely, so anyone reading
the file could act as an operator against any deployment that had not
overridden it. A default is worth less than it looks here: the deployment
that never set the variable is exactly the one where the default is public.
Every credential now comes from `.env`, and compose refuses to start naming
the variable it wanted. That also takes the last literal password out of a
tracked file.

**The origin ports are on loopback.** Both services speak plain HTTP and
mark no cookie `Secure`, because both expect to sit behind something that
terminates TLS. Published on every interface they were a way to reach the
issuer around that proxy, with sign-in codes and tokens in clear text.

**Mail settings are passed through rather than fixed.** The issuer was
pinned to printing sign-in codes to its log, and the three delivery
settings never reached it — so the documented way to configure mail could
not work, and every code and recipient went to the container log instead.
Printing codes is now asked for in `.env` like everything else, and with
nothing configured the issuer refuses to send rather than logging.

**Sandbox becomes a domain rather than a prefix.** `api.sandbox.nestri.io`
and `auth.sandbox.nestri.io`, because sandbox holds whatever is not
production and that set grows. One certificate for `*.sandbox.nestri.io`
then covers all of it, including unpredictable per-pull-request names,
and cannot be presented for production's own domain — which the zone-wide
wildcard the previous shape leaned on could.

Also drops `STEAM_API_KEY`. It was declared in two type definitions and
read by nothing: linking an account makes no outbound call that needs it.
2026-09-05 15:58:21 +03:00

60 lines
2.4 KiB
JSON

// The issuer, deployed as a Cloudflare Worker.
//
// The same `src/index.ts` also runs as an ordinary HTTP server — see
// `src/server.ts` and the `Dockerfile` beside it. Nothing in the handler is
// Workers-specific; what differs between the two is only where the settings
// below come from, so this file and the container's environment are two
// spellings of one list.
//
// Hostnames and the reasoning behind their shape: `docs/dns.md`.
// Secrets, the Hyperdrive id, and how to deploy: `docs/deploy.md`.
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "nestri-auth",
"main": "src/index.ts",
"compatibility_date": "2026-09-05",
"compatibility_flags": ["nodejs_compat"],
// No `*.workers.dev` hostname. A second address that mints tokens is a
// second issuer as far as a token's `iss` claim is concerned, and every
// token minted through it is rejected by the API.
"workers_dev": false,
"dev": {
"port": 1337
},
// Local-only settings live in `.dev.vars` beside this file rather than in
// `vars` here. `wrangler dev` reads that file and `wrangler deploy` cannot
// upload it — which is the guarantee wanted for the one setting in it:
// printing a live sign-in code to the log is a thing you ask for by name,
// and no stage anybody else can reach may have it. Written as a `vars`
// entry it would be one forgotten override away from being deployed.
// The default environment is the local one. `localConnectionString` is what
// `wrangler dev` uses, so a checkout with `docker compose up postgres`
// running needs nothing else; `id` is only read on deploy, and the two
// named environments below carry their own.
"hyperdrive": [
{
"binding": "HYPERDRIVE",
"id": "0000000000000000000000000000dev0",
"localConnectionString": "postgres://postgres:postgres@localhost:5432/nestri"
}
],
"env": {
"sandbox": {
"name": "nestri-auth-sandbox",
"workers_dev": false,
"routes": [{ "pattern": "auth.sandbox.nestri.io", "custom_domain": true }],
"observability": { "enabled": true },
"hyperdrive": [{ "binding": "HYPERDRIVE", "id": "<sandbox-hyperdrive-id>" }]
},
"production": {
"name": "nestri-auth",
"workers_dev": false,
"routes": [{ "pattern": "auth.nestri.io", "custom_domain": true }],
"observability": { "enabled": true },
"hyperdrive": [{ "binding": "HYPERDRIVE", "id": "<production-hyperdrive-id>" }]
}
}
}