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:
@@ -4,7 +4,8 @@
|
||||
import { execFileSync, spawn } from 'node:child_process'
|
||||
import { copyFileSync, existsSync, mkdirSync, mkdtempSync, openSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { BACKEND, CS, MASTER, OUT, PYTHON, WAITER, sleep } from './env.mjs'
|
||||
import { BACKEND, CS, OUT, PYTHON, WAITER, sleep } from './env.mjs'
|
||||
import { SUPPORT_MASTER, siteSecret, supportLogin } from './support.mjs'
|
||||
|
||||
/** Kill a process and its children (npx/shell wrappers on Windows). */
|
||||
export function killTree(child) {
|
||||
@@ -66,7 +67,7 @@ export async function startBackend({ port = 8055, siteId = 'test-site-1', siteKe
|
||||
SITE_ID: siteId, SITE_KEY: siteKey, CLOUD_URL: cloudUrl, SECRET_KEY: 'e2e-secret',
|
||||
// No cloud = a test backend: licensing off (every module). The license suite passes a cloudUrl.
|
||||
LICENSE_MODE: cloudUrl ? 'enforced' : 'off',
|
||||
MASTER_USERNAME: MASTER.username, MASTER_PASSWORD: MASTER.password, ...env,
|
||||
SUPPORT_SECRET: siteSecret(SUPPORT_MASTER, siteId), ...env,
|
||||
},
|
||||
})
|
||||
const url = `http://127.0.0.1:${port}`
|
||||
@@ -74,12 +75,8 @@ export async function startBackend({ port = 8055, siteId = 'test-site-1', siteKe
|
||||
return { url, dataDir, child, stop: async () => { killTree(child); await waitHttp(`${url}/api/system/health`, false).catch(() => {}) } }
|
||||
}
|
||||
|
||||
export async function login(baseUrl) {
|
||||
const r = await fetch(`${baseUrl}/api/auth/login`, {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(MASTER),
|
||||
})
|
||||
return (await r.json()).access_token
|
||||
}
|
||||
/** A superadmin token for a test backend, through support access (challenge code). */
|
||||
export const login = baseUrl => supportLogin(baseUrl)
|
||||
|
||||
/** nginx:alpine serving a waiter build (`dist`) with the waiter's own nginx.conf, /api → host backend. */
|
||||
export async function serveWaiterBuild({ name, port, dist = path.join(WAITER, 'dist'), backendPort = 8055 }) {
|
||||
@@ -121,7 +118,7 @@ export function composeStack({ project, version, siteId, http, https, manager, e
|
||||
writeFileSync(envFile, Object.entries({
|
||||
REGISTRY: 'e2e', VERSION: version, SITE_ID: siteId, SITE_KEY: 'x', CLOUD_URL: '', SECRET_KEY: 'e2e-secret',
|
||||
LICENSE_MODE: 'off',
|
||||
HOST_IP: '10.0.2.2', TLS_PORT: https, HTTP_PORT: http, MASTER_USERNAME: MASTER.username, MASTER_PASSWORD: MASTER.password,
|
||||
HOST_IP: '10.0.2.2', TLS_PORT: https, HTTP_PORT: http, SUPPORT_SECRET: siteSecret(SUPPORT_MASTER, siteId),
|
||||
DATA_PATH: fwd(path.join(dir, 'data')), LOGO_PATH: fwd(path.join(dir, 'logo.png')), FISCAL_PATH: fwd(path.join(dir, 'fiscal')),
|
||||
...extraEnv,
|
||||
}).map(([k, v]) => `${k}=${v}`).join('\n') + '\n')
|
||||
|
||||
Reference in New Issue
Block a user