Refuse a TRUST_PROXY the apps can't start with; Accounts reads loopback
A server configuration with TRUST_PROXY=TRUE made an Events install build for minutes, then fail: Express threw "invalid IP address: TRUE" at startup. - scripts/lib/envtpl.cjs: VALUE_RULES checked before any .env is written (exit 4, naming the value and the fix), for every release. - Contracts 1.6.0: agent.checkEnvValue / agent.invalidValues, the same rules for the Hub. - Accounts 1.0.1: TRUST_PROXY read as Events reads it; loopback used to turn proxy trust off. - Docs: CHANGELOGs, WHATS-NEW, HANDOVER, AGENT-1.0-PLAN, ROLLOUT-1.0, READMEs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,29 @@ import { Secrets } from '../src/lib/crypto.js';
|
||||
import { stateFor, type LicenceClaims } from '../src/hub/licence.js';
|
||||
import { normalisePhone } from '../src/accounts/service.js';
|
||||
import { waNumber } from '../src/lib/messages.js';
|
||||
import { loadConfig, trustProxyFrom } from '../src/lib/config.js';
|
||||
|
||||
describe('TRUST_PROXY', () => {
|
||||
test('read as Events reads it: loopback behind frp is on, not off', () => {
|
||||
assert.equal(trustProxyFrom('loopback', true), 'loopback');
|
||||
assert.deepEqual(trustProxyFrom('loopback, 203.0.113.10', true), ['loopback', '203.0.113.10']);
|
||||
assert.equal(trustProxyFrom('2', true), 2);
|
||||
assert.equal(trustProxyFrom('TRUE', true), 1);
|
||||
assert.equal(trustProxyFrom('true', false), 1);
|
||||
assert.equal(trustProxyFrom('false', true), false);
|
||||
assert.equal(trustProxyFrom('0', true), false);
|
||||
assert.equal(trustProxyFrom(undefined, true), 1);
|
||||
assert.equal(trustProxyFrom('', false), false);
|
||||
});
|
||||
|
||||
test('oidc-provider trusts the proxy whenever Express does', () => {
|
||||
const on = loadConfig({ NODE_ENV: 'test', TRUST_PROXY: 'loopback' });
|
||||
assert.equal(on.trustProxy, true);
|
||||
assert.equal(on.trustProxySetting, 'loopback');
|
||||
const off = loadConfig({ NODE_ENV: 'test', TRUST_PROXY: 'false' });
|
||||
assert.equal(off.trustProxy, false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('passwords', () => {
|
||||
test('Argon2id hashes verify, wrong passwords don\'t', async () => {
|
||||
|
||||
Reference in New Issue
Block a user