mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
* security: verify JWTs against an optional previous signing key DecodeJwt, the admin token checks and the volume expiry classifier take previous keys to try after the current one, and Guard keeps a previous write and read key next to the current ones. Signing still uses only the current key. Callers pass no previous key yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume, filer, s3, admin: accept tokens signed with jwt.*.previous_key jwt.signing.previous_key, jwt.signing.read.previous_key, jwt.filer_signing.previous_key and jwt.filer_signing.read.previous_key (WEED_JWT_*_PREVIOUS_KEY from the environment) name a key the verifiers still accept next to the current one, and SIGHUP reloads them. Keys can then rotate without an error window: add the new key as previous everywhere, swap current and previous, then remove previous. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: document jwt previous_key for key rotation Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): accept tokens signed with jwt.signing previous_key Mirrors the Go volume server: [jwt.signing] and [jwt.signing.read] take previous_key (WEED_JWT_SIGNING_PREVIOUS_KEY, WEED_JWT_SIGNING_READ_PREVIOUS_KEY), the guard verifies against it after the current key, and SIGHUP reloads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume, filer, s3: drop a removed previous_key on SIGHUP LoadConfiguration merges, so a previous_key line deleted from security.toml kept verifying until a restart. Read the previous keys without the merge on reload, as the Rust volume server already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume, filer, s3: keep previous keys when a reload cannot read the file A SIGHUP that found security.toml unreadable or malformed cleared the previous keys while the merged current keys stayed. Fall back to the merged configuration then, so the keys in effect stay in effect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: IAM and metadata subscription admin checks follow the filer guard The IAM gRPC service checked the jwt.filer_signing keys read at startup, and the metadata subscription read them from the merged configuration, so adding or removing previous_key with SIGHUP did not reach them. Both now read the filer guard that Reload updates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: reload jwt keys in one place, keeping the guard's previous keys When security.toml could not be read, the reloads fell back to the merged configuration, which still holds a previous_key an earlier reload removed. Guard.ReloadSigningKeys keeps the previous keys the guard already has instead, and the volume, filer and S3 reloads share it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: take reloaded current keys from the same read as previous keys The current keys came from the merged configuration and the previous keys from a second read of the file, so a file swapped between the two reads could publish the same key as both. Take every key the fresh read sets from it; a current key the file no longer sets keeps its merged value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: worker streams read the filer admin keys as security.toml sets them Both worker stream handlers read jwt.filer_signing keys from the merged configuration. Under weed mini a reload merges the file, which keeps a previous_key the operator removed, so new streams still accepted it; a standalone admin never picked up a rotation at all. Read the keys the file sets now, falling back to the merged values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: wait for old-key tokens to expire before clearing previous_key Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): keep the keys in effect when SIGHUP cannot read security.toml parse_security_config falls back to defaults when the file is missing or unreadable, so a SIGHUP then cleared every key and turned JWT checks off. Skip the key and whitelist update in that case, as the Go reload keeps its merged configuration and the guard's previous keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: keep every key in effect when a reload cannot read security.toml A failed read took the current keys from the merged configuration while keeping the active previous keys, so after a swapped pair the guard could publish the old key twice and reject tokens signed with the new one. The reload now leaves the keys untouched, as the Rust volume server does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: filer admin keys fall back to the last pair read, not merged values When security.toml stopped being readable, FilerAdminKeys returned the merged configuration, which still holds a previous_key the file had already dropped, so tokens signed with the retired key verified again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: STS store gates check the admin token against one key snapshot The OIDC provider and role RPCs read the reloadable admin key twice, in checkAdminAuth and in the store gate. A reload that set the key between the two reads let a call without a token pass both. The gate now takes one snapshot for the empty-key refusal and the token check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: read and cache filer admin keys under one lock Concurrent callers could store their reads out of order, so an older pair that still had previous_key could overwrite a newer one and come back when a later read of security.toml failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: unlock the filer admin key mutex on every exit of its test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
331 lines
14 KiB
TOML
331 lines
14 KiB
TOML
# Put this file to one of the location, with descending priority
|
|
# ./security.toml
|
|
# $HOME/.seaweedfs/security.toml
|
|
# /etc/seaweedfs/security.toml
|
|
# this file is read by master, volume server, filer, and worker
|
|
|
|
# Any value below can also be supplied as an environment variable instead of
|
|
# living in this file: prefix the key with WEED_, upper-case it, and replace
|
|
# "." with "_". This is the recommended way to inject the secrets in here from
|
|
# a Kubernetes Secret (env valueFrom.secretKeyRef) rather than a ConfigMap.
|
|
# The JWT signing keys map to these env vars. When each component gets its own
|
|
# set, give it every key it signs or verifies with:
|
|
# WEED_JWT_SIGNING_KEY master, volume, filer, weed shell
|
|
# WEED_JWT_SIGNING_READ_KEY master, volume, and every process that
|
|
# reads chunks from volume servers: filer,
|
|
# s3, mount, webdav, sftp, filer.sync,
|
|
# filer.backup, workers, admin, weed shell
|
|
# WEED_JWT_FILER_SIGNING_KEY filer, s3, admin and workers (admin IAM and
|
|
# worker gRPC calls), and clients of the filer
|
|
# HTTP API
|
|
# WEED_JWT_FILER_SIGNING_READ_KEY filer, s3, and clients of the filer HTTP API
|
|
# WEED_JWT_FILER_SIGNING_SUBSCRIBE_KEY filer metadata subscriptions
|
|
# A set env var wins over the file, so the file can stay empty (or absent).
|
|
|
|
# comma separated origins allowed to make requests to the filer and s3 gateway.
|
|
# enter in this format: https://domain.com, or http://localhost:port
|
|
[cors.allowed_origins]
|
|
values = "*"
|
|
|
|
# this jwt signing key is used for write operations on volume servers:
|
|
# - the Master server generates the JWT, which can be used to write a certain file on a volume server
|
|
# - the Filer generates it for the chunk writes it proxies to volume servers,
|
|
# and weed shell for fs.merge_volumes and fs.distribute_chunks
|
|
# - the Volume server validates the JWT on writing
|
|
# the jwt defaults to expire after 10 seconds.
|
|
[jwt.signing]
|
|
key = ""
|
|
expires_after_seconds = 10 # seconds
|
|
# Optional. A key that is still accepted when verifying, but never used to
|
|
# sign, so keys can rotate without rejected requests: set the new key as
|
|
# previous_key everywhere, then swap key and previous_key everywhere, then,
|
|
# once tokens signed with the old key have expired, clear previous_key.
|
|
# Reload (SIGHUP) or restart after each step. [jwt.signing.read],
|
|
# [jwt.filer_signing] and [jwt.filer_signing.read] take previous_key the same way.
|
|
# Env: WEED_JWT_SIGNING_PREVIOUS_KEY, WEED_JWT_SIGNING_READ_PREVIOUS_KEY,
|
|
# WEED_JWT_FILER_SIGNING_PREVIOUS_KEY, WEED_JWT_FILER_SIGNING_READ_PREVIOUS_KEY
|
|
previous_key = ""
|
|
|
|
# by default, if the signing key above is set, the Volume UI over HTTP is disabled.
|
|
# by setting ui.access to true, you can re-enable the Volume UI. Despite
|
|
# some information leakage (as the UI is not authenticated), this should not
|
|
# pose a security risk.
|
|
[access]
|
|
ui = false
|
|
|
|
# by default the filer UI is enabled. This can be a security risk if the filer is exposed to the public
|
|
# and the JWT for reads is not set. If you don't want the public to have access to the objects in your
|
|
# storage, and you haven't set the JWT for reads it is wise to disable access to directory metadata.
|
|
# This disables access to the Filer UI, and will no longer return directory metadata in GET requests.
|
|
[filer.expose_directory_metadata]
|
|
enabled = true
|
|
|
|
# HTTP Basic Auth on the filer HTTP ports (-port and -port.readonly). Once the
|
|
# password is set, every request needs these credentials or a valid filer JWT
|
|
# (see [jwt.filer_signing]), and an access level without a JWT key is no longer
|
|
# open. /healthz and /readyz stay open. A browser request from another website
|
|
# (an Origin other than the filer's own host) can use these credentials only if
|
|
# its origin is listed in cors.allowed_origins. Components that call the filer HTTP
|
|
# port (mount, filer.sync and filer.backup with -filerProxy, sftp, volume.fsck)
|
|
# authenticate with the filer JWT, so set jwt.filer_signing.key, and
|
|
# jwt.filer_signing.read.key for their reads, if you run them.
|
|
# Env: WEED_FILER_BASIC_AUTH_USER, WEED_FILER_BASIC_AUTH_PASSWORD
|
|
[filer.basic_auth]
|
|
user = ""
|
|
password = ""
|
|
|
|
# this jwt signing key is used for read operations on volume servers:
|
|
# - the Master server generates the JWT, which can be used to read a certain file on a volume server
|
|
# - every process that reads chunks straight from volume servers generates its
|
|
# own: filer, s3, mount, webdav, sftp, filer.sync, filer.backup, workers,
|
|
# admin and weed shell. Without the key, their reads fail with "wrong jwt".
|
|
# - the Volume server validates the JWT on reading
|
|
[jwt.signing.read]
|
|
key = ""
|
|
expires_after_seconds = 10 # seconds
|
|
previous_key = ""
|
|
|
|
|
|
# If this JWT key is configured, Filer only accepts writes over HTTP if they are signed with this JWT:
|
|
# - f.e. the S3 API Shim generates the JWT
|
|
# - the Filer server validates the JWT on writing
|
|
# NOTE: This key is ALSO used as a fallback signing key for S3 STS if s3.iam.config does not specify a signingKey.
|
|
# NOTE: This key also gates the filer IAM gRPC service (CreateUser, PutPolicy,
|
|
# CreateAccessKey, ...). When set, every IAM RPC must carry a Bearer
|
|
# token signed with this key in its "authorization" gRPC metadata; mint
|
|
# such a token with security.GenJwtForFilerAdmin. When empty, the IAM
|
|
# gRPC service runs unauthenticated and refuses its OIDC provider and
|
|
# role RPCs. When set, set it on both filer and admin.
|
|
# The key does not protect the other filer gRPC RPCs, which can read and
|
|
# write the IAM store under /etc/iam; if the filer gRPC port is reachable
|
|
# beyond a trusted network, enable [grpc.filer] mTLS below.
|
|
# the jwt defaults to expire after 10 seconds.
|
|
[jwt.filer_signing]
|
|
key = ""
|
|
expires_after_seconds = 10 # seconds
|
|
previous_key = ""
|
|
|
|
# If this JWT key is configured, Filer only accepts reads over HTTP if they are signed with this JWT:
|
|
# - f.e. the S3 API Shim generates the JWT
|
|
# - the Filer server validates the JWT on reading
|
|
# the jwt defaults to expire after 10 seconds.
|
|
[jwt.filer_signing.read]
|
|
key = ""
|
|
expires_after_seconds = 10 # seconds
|
|
previous_key = ""
|
|
|
|
# Optional. If this key is set, the filer's SubscribeMetadata and
|
|
# SubscribeLocalMetadata gRPC calls require an mTLS-verified peer, an admin
|
|
# token signed with jwt.filer_signing.key, or a read-only token signed with this
|
|
# key. That token is an HS256 JWT with "exp", "allowed_methods" (a subset of
|
|
# SubscribeMetadata and SubscribeLocalMetadata) and "allowed_prefixes"
|
|
# (absolute paths); its holder only receives events whose paths are all under
|
|
# one of the prefixes. Mint one with "fs.meta.token" in weed shell. Without
|
|
# mTLS, set jwt.filer_signing.key and this key on every filer, S3 gateway,
|
|
# mount and filer.sync too, so they keep full access.
|
|
[jwt.filer_signing.subscribe]
|
|
key = ""
|
|
|
|
# gRPC mTLS configuration
|
|
# All gRPC TLS authentications are mutual (mTLS)
|
|
# The values for ca, cert, and key are paths to the certificate/key files
|
|
# The host name is not checked, so the certificate files can be shared.
|
|
# Set verify_server_host = true under [grpc] or a [grpc.<component>] section to
|
|
# require that a server certificate is valid for the host or IP that component
|
|
# dials, as the Rust volume server always does.
|
|
# Each [grpc.<component>] section also accepts optional client_cert/client_key,
|
|
# presented when that component dials other servers. Set them when your CA
|
|
# issues separate serverAuth-only and clientAuth-only certificates; when unset,
|
|
# the component reuses cert/key for both directions.
|
|
# If client and server certificates come from different issuing CAs, put both
|
|
# CA certificates in the ca PEM file.
|
|
# Once a component's cert/key are set, any error loading them or grpc.ca is
|
|
# fatal: the component never falls back to plaintext.
|
|
[grpc]
|
|
ca = ""
|
|
verify_server_host = false
|
|
# Set wildcard domain for enable TLS authentication by common names
|
|
allowed_wildcard_domain = "" # .mycompany.com
|
|
# Optional allowlist a client checks the dialed server's certificate against:
|
|
# the subject common name, a DNS SAN, or a URI SAN (e.g. a SPIFFE id) must be
|
|
# listed, or match allowed_server_wildcard_domain, else the handshake fails.
|
|
# With a per-workload CA, list the identities each server may present so one
|
|
# workload cannot impersonate another component. Unset accepts any CA-signed
|
|
# server certificate, as before. Any [grpc.<component>] section may set its own
|
|
# allowed_server_commonNames to override this list. Only the filer scopes it
|
|
# further per dialed target: [grpc.filer] master_, volume_ and
|
|
# s3_allowed_server_commonNames. Other components dial every server with one
|
|
# allowlist and refuse to start when per-target keys are their only allowlist.
|
|
allowed_server_commonNames = "" # comma-separated server identities
|
|
allowed_server_wildcard_domain = "" # .mycompany.com
|
|
|
|
# Volume server gRPC options (server-side)
|
|
# Enables mTLS for incoming gRPC connections to volume server
|
|
[grpc.volume]
|
|
cert = ""
|
|
key = ""
|
|
client_cert = ""
|
|
client_key = ""
|
|
allowed_commonNames = "" # comma-separated SSL certificate common names
|
|
|
|
# Master server gRPC options (server-side)
|
|
# Enables mTLS for incoming gRPC connections to master server
|
|
[grpc.master]
|
|
cert = ""
|
|
key = ""
|
|
client_cert = ""
|
|
client_key = ""
|
|
allowed_commonNames = "" # comma-separated SSL certificate common names
|
|
|
|
# Filer server gRPC options (server-side)
|
|
# Enables mTLS for incoming gRPC connections to filer server
|
|
[grpc.filer]
|
|
cert = ""
|
|
key = ""
|
|
client_cert = ""
|
|
client_key = ""
|
|
allowed_commonNames = "" # comma-separated SSL certificate common names
|
|
|
|
# S3 server gRPC options (server-side)
|
|
# Enables mTLS for incoming gRPC connections to S3 server
|
|
[grpc.s3]
|
|
cert = ""
|
|
key = ""
|
|
client_cert = ""
|
|
client_key = ""
|
|
allowed_commonNames = "" # comma-separated SSL certificate common names
|
|
|
|
[grpc.msg_broker]
|
|
cert = ""
|
|
key = ""
|
|
client_cert = ""
|
|
client_key = ""
|
|
allowed_commonNames = "" # comma-separated SSL certificate common names
|
|
|
|
[grpc.msg_agent]
|
|
cert = ""
|
|
key = ""
|
|
client_cert = ""
|
|
client_key = ""
|
|
allowed_commonNames = "" # comma-separated SSL certificate common names
|
|
|
|
[grpc.admin]
|
|
cert = ""
|
|
key = ""
|
|
client_cert = ""
|
|
client_key = ""
|
|
allowed_commonNames = "" # comma-separated SSL certificate common names
|
|
|
|
[grpc.worker]
|
|
cert = ""
|
|
key = ""
|
|
client_cert = ""
|
|
client_key = ""
|
|
allowed_commonNames = "" # comma-separated SSL certificate common names
|
|
|
|
[grpc.mq]
|
|
cert = ""
|
|
key = ""
|
|
client_cert = ""
|
|
client_key = ""
|
|
allowed_commonNames = "" # comma-separated SSL certificate common names
|
|
|
|
# weed-vector gRPC options (server-side)
|
|
# Enables mTLS for incoming gRPC connections to the vector engine; the S3
|
|
# gateway dials it with [grpc.client], and the engine dials the masters with
|
|
# [grpc.client] too. The files are re-read every WEED_TLS_CERT_REFRESH_INTERVAL
|
|
# (default 5h) and on SIGHUP.
|
|
[grpc.vector]
|
|
cert = ""
|
|
key = ""
|
|
allowed_commonNames = "" # comma-separated SSL certificate common names
|
|
|
|
# gRPC client configuration for outgoing gRPC connections
|
|
# Used by clients (S3, mount, backup, benchmark, filer.copy, filer.replicate, upload, etc.)
|
|
# when connecting to any gRPC server (master, volume, filer)
|
|
[grpc.client]
|
|
cert = ""
|
|
key = ""
|
|
|
|
# HTTPS client configuration for outgoing HTTP connections
|
|
# Used by S3, mount, filer.copy, backup, and other clients when communicating with master/volume/filer
|
|
# Set enabled=true to use HTTPS instead of HTTP for data operations (separate from gRPC)
|
|
# If [https.filer] or [https.volume] are enabled on servers, clients must have [https.client] enabled=true
|
|
[https.client]
|
|
enabled = false # Set to true to enable HTTPS for all outgoing HTTP client connections
|
|
cert = "" # Client certificate for mTLS (optional if server doesn't require client cert)
|
|
key = "" # Client key for mTLS (optional if server doesn't require client cert)
|
|
ca = "" # CA certificate to verify server certificates (required when enabled=true)
|
|
insecure_skip_verify = false # Skip TLS certificate verification (NOT recommended for production)
|
|
|
|
# Volume server HTTPS options (server-side)
|
|
# Enables HTTPS for incoming HTTP connections to volume server
|
|
[https.volume]
|
|
cert = ""
|
|
key = ""
|
|
ca = ""
|
|
|
|
# Master server HTTPS options (server-side)
|
|
# Enables HTTPS for incoming HTTP connections to master server (web UI, HTTP API)
|
|
[https.master]
|
|
cert = ""
|
|
key = ""
|
|
ca = ""
|
|
|
|
# Filer server HTTPS options (server-side)
|
|
# Enables HTTPS for incoming HTTP connections to filer server (web UI, HTTP API)
|
|
[https.filer]
|
|
cert = ""
|
|
key = ""
|
|
ca = ""
|
|
# disable_tls_verify_client_cert = true|false (default: false)
|
|
|
|
# Admin server HTTPS options (server-side)
|
|
# Enables HTTPS for incoming HTTP connections to admin server
|
|
[https.admin]
|
|
cert = ""
|
|
key = ""
|
|
ca = ""
|
|
|
|
# Admin server authentication
|
|
# If password is set, users must login to access the admin interface
|
|
# These can be overridden by environment variables with WEED_ prefix:
|
|
# WEED_ADMIN_USER, WEED_ADMIN_PASSWORD
|
|
# WEED_ADMIN_READONLY_USER, WEED_ADMIN_READONLY_PASSWORD
|
|
[admin]
|
|
user = ""
|
|
password = ""
|
|
|
|
[admin.readonly]
|
|
user = ""
|
|
password = ""
|
|
|
|
# SSE-S3 server-side encryption key management
|
|
# These settings configure the Key Encryption Key (KEK) for S3 SSE-S3 encryption.
|
|
# Set exactly one of kek or key. If neither is set, SSE-S3 is disabled.
|
|
# Can also be set via env vars: WEED_S3_SSE_KEK, WEED_S3_SSE_KEY
|
|
[s3.sse]
|
|
# hex-encoded 256-bit key, same format as the legacy /etc/s3/sse_kek filer file.
|
|
# Use this to migrate from a filer-stored KEK: copy the value from /etc/s3/sse_kek.
|
|
# Generate a new one with: openssl rand -hex 32
|
|
kek = ""
|
|
# any secret string; a 256-bit key is derived automatically via HKDF-SHA256.
|
|
# Cannot be used while /etc/s3/sse_kek exists on the filer — delete it first.
|
|
key = ""
|
|
|
|
# Trusted reverse proxies allowed to set forwarding headers on behalf of the
|
|
# real client: X-Forwarded-For / X-Real-Ip for aws:SourceIp condition
|
|
# evaluation in S3 bucket and IAM policies, and X-Forwarded-Prefix for SigV4
|
|
# signature verification of prefix-stripped paths. When the direct TCP peer is
|
|
# in this list, these headers are honored; otherwise they are ignored. A
|
|
# trusted proxy must overwrite or strip client-supplied values of these
|
|
# headers, since honoring them means trusting them. Leave empty to always use
|
|
# the direct peer, which is the safe default.
|
|
# Can also be set via env var: WEED_S3_TRUSTED_PROXIES_WHITE_LIST
|
|
[s3.trusted_proxies]
|
|
white_list = "" # comma separated; bare IPs or CIDRs, e.g. "10.10.10.0/24"
|
|
|
|
# white list. It's checking request ip address.
|
|
[guard]
|
|
white_list = ""
|