diff options
| author | Adam Soltys <[email protected]> | 2026-12-04 17:24:25 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-12-04 17:24:25 -0700 |
| commit | d1db874a6e3c3c488331f3117f41b48480354f4e (patch) | |
| tree | 18d38dae915ac4efcefe2ac336223689ec1933c2 /routes/users.ts | |
| parent | dfe22eee4e698731c3e31420250bb158f2d4b2d5 (diff) | |
| download | coinos-server-HEAD.tar.gz coinos-server-HEAD.zip | |
Admin only from Adam's addresses: the admin account's sessions and the admin password are refused from anywhere else.HEADmasterHEAD
After the 2026-12-04 desk breach the JWT secret was kept, so a copied or forged admin session must be useless off Adam's networks. config.adminIps lists exact addresses and IPv4 ranges; a request is judged by its Cloudflare client address (the app is only reachable through the tunnel and Caddy), and Tor pages never qualify. A global preHandler (after each route's auth) answers 403 to an admin session from elsewhere; the master-password login and freeze only accept adminpass from an allowed address. Unset or empty adminIps keeps the old behaviour.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VMan6WoqaQDYdpWkatPCar
Diffstat (limited to 'routes/users.ts')
| -rw-r--r-- | routes/users.ts | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/routes/users.ts b/routes/users.ts index a4c8f3da..af195153 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -3,6 +3,7 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import config from "$config"; import { checkPin, requirePin } from "$lib/auth"; +import { adminIpAllowed } from "$lib/adminip"; import { db, g, gf, s } from "$lib/db"; import { err, l, warn } from "$lib/logging"; import { isDefaultName } from "$lib/default-names"; @@ -551,7 +552,8 @@ export default { // undefined). Both the configured value and the supplied one must be // non-empty and match exactly. const isAdmin = - !!config?.adminpass && !!password && password === config.adminpass; + !!config?.adminpass && !!password && password === config.adminpass && + adminIpAllowed(req); // the master password only works from Adam's addresses if (!isAdmin) { const recaptchaOk = await verifyRecaptcha(recaptcha, req, { |
