feat(backend): support access by offline challenge codes replaces the master account

Platform v2 step 1.10 (APPS_PLATFORM D-16, section 6.5).
- POST /api/auth/support/challenge (public): an 8-character challenge, stored 15 min
  (support_challenges, revision 0009; at most 5 open). POST /api/auth/support/verify
  {challenge, code}: code = base32(HMAC(SUPPORT_SECRET, site_id + challenge))[:10];
  single use, 5 wrong codes burn the challenge. Opens a 4 h support session
  (client=support, synthetic superadmin) with a hard end: sessions.expires_at.
- core/support_codes.py (stdlib only) is the derivation; tools/support_code.py
  (--init, --site-secret <SITE_ID>, <SITE_ID> <CHALLENGE>) uses it on the builder's
  machine with the master key in %USERPROFILE%/.xenia/support_master_key.txt.
- MASTER_USERNAME/MASTER_PASSWORD removed (config, login, docker-compose.yml,
  .env.example); SUPPORT_SECRET added; install.sh asks for it.
- e2e: backends get SUPPORT_SECRET from a test master key and log in with challenge
  codes (lib/support.mjs, license_e2e.py); install.mjs expects the new prompt.
- Pack rule CS-15.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 10:52:16 +02:00
co-authored by Claude Opus 5.5
parent 650fee7873
commit 3a522e457d
23 changed files with 517 additions and 52 deletions
+3 -3
View File
@@ -39,8 +39,8 @@ host eth0; DEFAULT_ROUTE=""; echo "DETECT no-d
host wlan0; DEFAULT_ROUTE="default via 192.168.1.1 dev wlan0"; echo "DETECT wifi-only=$(detect_host_ip)"
# full install.sh flows (real ip/hostname again, docker stubbed)
rm /stub/ip /stub/hostname; unset XENIA_SYS_NET
cp -r /t /a && cd /a && printf 'site-123\\nkey-abc\\n\\n\\n' | bash install.sh >/dev/null
echo "FRESH env=$(grep -cE '^(SITE_ID=site-123|SITE_KEY=key-abc|HOST_IP=.+)$' .env) cert=$(test -s certs/cert.pem && echo yes) keymode=$(stat -c %a certs/key.pem) conf=$(test -s nginx-proxy/nginx.conf && echo yes)"
cp -r /t /a && cd /a && printf 'site-123\\nkey-abc\\n\\n\\nsupp-0123abcd\\n' | bash install.sh >/dev/null
echo "FRESH env=$(grep -cE '^(SITE_ID=site-123|SITE_KEY=key-abc|HOST_IP=.+|SUPPORT_SECRET=supp-0123abcd)$' .env) cert=$(test -s certs/cert.pem && echo yes) keymode=$(stat -c %a certs/key.pem) conf=$(test -s nginx-proxy/nginx.conf && echo yes)"
cp -r /t /b && cd /b && mkdir -p certs && cp /a/certs/* certs/ && grep -v '^HOST_IP' .env.example > .env
bash install.sh >/dev/null; echo "UPGRADE hostip=$(grep -c '^HOST_IP=.\\+' .env)"
bash install.sh >/dev/null; echo "RERUN hostip_lines=$(grep -c '^HOST_IP=' .env)"
@@ -54,7 +54,7 @@ r.check('HOST_IP: WireGuard full tunnel → physical NIC', val('DETECT wg-full-t
r.check('HOST_IP: tunnel owns the default route → physical NIC', val('DETECT tunnel-owns-default') === '10.98.20.70')
r.check('HOST_IP: no default route → physical NIC', val('DETECT no-default-route') === '10.98.20.70')
r.check('HOST_IP: WiFi-only server', val('DETECT wifi-only') === '192.168.1.44')
r.check('fresh install: .env filled (SITE_ID, SITE_KEY, HOST_IP)', val('env') === '3')
r.check('fresh install: .env filled (SITE_ID, SITE_KEY, HOST_IP, SUPPORT_SECRET)', val('env') === '4')
r.check('fresh install: self-signed cert, key 600, proxy config written', val('cert') === 'yes' && val('keymode') === '600' && val('conf') === 'yes')
r.check('upgrade: missing HOST_IP backfilled', val('UPGRADE hostip') === '1')
r.check('re-run: HOST_IP not duplicated', val('RERUN hostip_lines') === '1')