mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-20 03:13:53 +01:00
* security: add a constant-time HTTP Basic Auth check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: require HTTP Basic Auth on the HTTP ports when configured With filer.basic_auth.password set in security.toml (or WEED_FILER_BASIC_AUTH_PASSWORD), a request on the filer HTTP ports, TUS included, must carry those credentials or a valid filer JWT, and an access level with no JWT signing key is no longer open. Valid Basic credentials grant read and write. 401 responses then carry a Basic challenge so browsers prompt. The credentials reload on SIGHUP with the signing keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: document filer.basic_auth in security.toml Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: enable reloaded Basic Auth before swapping the JWT keys Reload cleared the old signing keys before storing the new Basic credentials, so a switch from JWT to Basic Auth briefly left both off and admitted anonymous requests. Store new credentials first and clear old ones last. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: refuse Basic credentials on cross-origin browser requests Browsers resend cached Basic credentials on requests other websites trigger, such as a form POST with mv.from, and the default cors.allowed_origins "*" lets them through. Accept Basic credentials only on requests without an Origin, from the filer's own host, or from an origin explicitly listed in cors.allowed_origins. A JWT is still accepted from any origin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: recheck Basic Auth after reading an empty signing key A request that loaded Basic Auth as off, then read the signing key after a JWT-to-Basic Reload had cleared it, was let through anonymously. Open access now also needs Basic Auth to be off after the key read; with Reload enabling the new credential before disabling the old one, the two loads cannot both miss a credential that was on throughout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: compare Basic Auth credentials as MACs under a per-process key A plain SHA-256 of the password is what password-hash scanners flag; keying the digests with a random per-process HMAC key keeps the length-independent constant-time compare without holding one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: read a configuration file without merging into the shared viper LoadConfiguration merges each read into the shared viper, so a key removed from the file keeps its old value after a reload. ReadConfiguration reads the file into a fresh viper with the same search path and WEED_ environment overrides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: turn Basic Auth off when security.toml no longer sets it The shared viper merges each SIGHUP reload into what it held, so removing [filer.basic_auth] kept the old password valid. Read the credentials from security.toml alone at startup and on reload; an unreadable file keeps the current setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep Basic Auth when security.toml cannot be read A malformed file at startup dropped a WEED_FILER_BASIC_AUTH_PASSWORD from the environment, and viper reports an unsearchable config directory as a missing file, which turned Basic Auth off on reload. ReadConfiguration now always returns the environment overrides and reports whether the file was read; a reload that could not read it keeps the current credentials. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep reloading Basic Auth from the security.toml first read A search directory that turned unsearchable made viper fall through to a lower-priority security.toml, and a reload from a file without [filer.basic_auth] turned Basic Auth off. ReadConfiguration now takes the file to read, and the filer reads the file it first found on every reload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>