A ZM_AUTH_HASH_SECRET that is too short or the shipped default is refused
for tokens, and the log line said to set it in Options or run
zmupdate.pl -f. Both only change the Config table, so neither helps when
zm.conf or a conf.d file sets the secret: Options shows it read-only and
the file value keeps winning.
authHashSecretFix() names the file when one sets the secret, using the
same loadConfigFiles() Options uses to mark file-set values.
Reported in review by nabbi.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Config.Name is the primary key, and Model::set() moves the save to whatever
Name the request body carries. A PUT to configs/edit/ZM_LANG_DEFAULT with
{"Config":{"Name":"ZM_AUTH_HASH_SECRET","Value":"short"}} validated the
language row and saved a short secret. Call pinRequestId() first, as the
other controllers' edit actions do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The length check read only Config[Value], but Model::set() also saves a bare
Value when the request has no Config entry, so {"Value":"short"} stored a
secret too short for php-jwt and turned off token login. Read the value with
requestField(), as the other API checks do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The php-jwt check decoded with Firebase\JWT\Key, which php-jwt 5 (still
in upstream web/vendor) does not have, and expected php-jwt to refuse a
31 character key, which only php-jwt 7 does. Encode only, and require
agreement only when php-jwt enforces the minimum; otherwise check that
an accepted secret works.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zm_create.sql is generated at build time, so every new install's Config
table holds the public shipped default secret. zmupdate.pl -f replaces
it, but the rpm %post runs -f only on upgrade, and containers or a
database created by hand from zm_create.sql never run it. Token auth
then refuses to work until the admin sets a secret.
loadConfig() now passes the secret through ensureAuthHashSecret(): a
default or empty value is replaced with bin2hex(random_bytes(32)) and
stored. The UPDATE matches the old value and the stored value is read
back, so concurrent first requests agree on one secret. A secret set in
zm.conf or conf.d is left alone.
ZM_AUTH_HASH_SECRET_DEFAULT moves from auth.php to config.php.in, which
loads first.
Tests: tests/php/test_auth_hash_secret_generate.php.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit a844cf136827d175f8dd02400c9755923bd28f1c)
php-jwt 7 refuses an HS256 key shorter than 32 bytes, so a hand-set
ZM_AUTH_HASH_SECRET shorter than that made every token login fail, and
HostController::login() returned a 500 from an uncaught DomainException.
- auth.php: add ZM_AUTH_HASH_SECRET_MIN_LENGTH and authHashSecretValid().
authHashSecretIsSet() uses it, so validateToken() and the API login
refuse a short secret with a message instead of throwing.
- Options save (actions/options.php) and the API configs edit refuse a
new secret that is shorter than 32 characters or the shipped default.
- zmupdate.pl -f: generateAuthHashSecret() extends an existing short
secret by repeating it until it is at least 32 characters, through the
new ConfigData::extendAuthHashSecret(). The user's secret is kept.
- Option help text states the minimum length.
Tests: tests/php/test_auth_hash_secret_length.php checks the rule and
that it agrees with php-jwt; tests/perl/test_auth_hash_secret_extend.pl
checks the upgrade extension.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 4480b18135d736fcd87e8ed43a45e41d55688a8d)