diff options
| author | tv <tv@krebsco.de> | 2026-11-07 01:59:38 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-07 01:59:38 +0100 |
| commit | 09b4f7daac52b5aa6cebaa9c147a9086b105aac9 (patch) | |
| tree | 2e18e044e9e1c6b690fe1cfd1f95517a4fcf503c /src/config | |
| parent | 4479bb89595958721a2dfef57dbcb89b255a7ad8 (diff) | |
access first usersauth
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/mod.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index db700ef..d1c3953 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -124,6 +124,13 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[ "HTTP API users (from htpasswd or user-header) who may write protocol data under /store/_continuum (remake records, members, forget records), e.g. to repair a stuck remake. Such writes act on the whole swarm and are logged. Epoch metadata and the swarm ID are never writable.", ), option( + "bootstrap-users", + Kind::List, + "USER,[USER...]", + None, + "With genesis: the new swarm's first users, each may do everything, protocol data and managing users included (docs/access.md). Unset, the users of htpasswd may read and write the swarm's data, and those also in protocol-writers everything. A swarm nobody could manage doesn't start: set this, or protocol-writers, for one of htpasswd's users.", + ), + option( "log-format", Kind::Text, "auto|text|journal", @@ -535,6 +542,8 @@ pub(crate) struct Settings { #[serde(default)] pub(crate) protocol_writers: Vec<String>, #[serde(default)] + pub(crate) bootstrap_users: Vec<String>, + #[serde(default)] pub(crate) debug_api: bool, #[serde(default = "default_log_format")] pub(crate) log_format: String, @@ -751,6 +760,18 @@ impl Settings { if self.remake.is_some() && !self.genesis { bail!("remake makes a new swarm's document; it needs genesis"); } + if !self.bootstrap_users.is_empty() && !self.genesis { + bail!( + "bootstrap-users names the first users of a new swarm; it needs genesis (drop it once the swarm exists)" + ); + } + if let Some(bad) = self + .bootstrap_users + .iter() + .find(|name| !crate::access::registry::valid_name(name)) + { + bail!("bootstrap-users: {bad:?} isn't a user name (1 to 64 of A-Z a-z 0-9 . _ @ -)"); + } if self.genesis && self.recover_from.is_some() { bail!("recover-from starts the swarm from a backup; it can't be combined with genesis"); } @@ -899,6 +920,7 @@ impl Settings { ("swarm-key-file", self.swarm_key_file.is_some()), ("swarm-key-create", self.swarm_key_create), ("protocol-writers", !self.protocol_writers.is_empty()), + ("bootstrap-users", !self.bootstrap_users.is_empty()), ("alias", self.alias.is_some()), ("dashboard-url", self.dashboard_url.is_some()), ("debug-api", self.debug_api), |
