aboutsummaryrefslogtreecommitdiffstats
path: root/src/access/registry.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-07 22:35:09 +0100
committertv <tv@krebsco.de>2026-11-07 22:35:09 +0100
commit3a9d9da74f55395ead20f3915ed04639e37b2f03 (patch)
tree1cb7d8cb8ff3acd8ce87b9169d535c9d36561fef /src/access/registry.rs
parent75ba06027496df9cea0054d8d8e9c504031d1b2c (diff)
access: bootstrap users only
The first users come only from --bootstrap-users; the genesis node warns of htpasswd users that aren't among them. Auth plan M1.
Diffstat (limited to 'src/access/registry.rs')
-rw-r--r--src/access/registry.rs35
1 files changed, 9 insertions, 26 deletions
diff --git a/src/access/registry.rs b/src/access/registry.rs
index 094e62c..3006b31 100644
--- a/src/access/registry.rs
+++ b/src/access/registry.rs
@@ -146,24 +146,12 @@ pub(crate) fn capability(by: &str, since: u64, path: &[String], rights: &[Right]
/// included), not only read and write the swarm's data.
pub(crate) type FirstUsers = Vec<(String, bool)>;
-/// The first users of a new swarm, from the genesis node's options: those of
-/// `bootstrap_users` may do everything, and the other users of its htpasswd file
-/// (`htpasswd`) read and write the swarm's data. None without `bootstrap_users`: then
-/// the swarm has no registry, and its users are all alike, as before there were
-/// registries (`access.md`).
-pub(crate) fn first_users(bootstrap_users: &[String], htpasswd: &[String]) -> FirstUsers {
- if bootstrap_users.is_empty() {
- return Vec::new();
- }
- let mut users: BTreeMap<String, bool> = htpasswd
- .iter()
- .filter(|name| valid_name(name))
- .map(|name| (name.clone(), false))
- .collect();
- for name in bootstrap_users {
- users.insert(name.clone(), true);
- }
- users.into_iter().collect()
+/// The first users of a new swarm, from the genesis node's `--bootstrap-users`: each may
+/// do everything. None without: then the swarm has no registry, and its users are all
+/// alike, as before there were registries (`access.md`).
+pub(crate) fn first_users(bootstrap_users: &[String]) -> FirstUsers {
+ let users: std::collections::BTreeSet<&String> = bootstrap_users.iter().collect();
+ users.into_iter().map(|name| (name.clone(), true)).collect()
}
/// The capabilities of a first user (`first_users`): the swarm's data, and for one who
@@ -261,16 +249,11 @@ mod tests {
fn the_first_users() {
let names = |list: &[&str]| list.iter().map(|n| (*n).to_owned()).collect::<Vec<_>>();
assert_eq!(
- first_users(&names(&["alice"]), &names(&["alice", "bob"])),
- vec![("alice".to_owned(), true), ("bob".to_owned(), false)]
- );
- // One the proxy names, not in htpasswd.
- assert_eq!(
- first_users(&names(&["carol"]), &names(&["bob"])),
- vec![("bob".to_owned(), false), ("carol".to_owned(), true)]
+ first_users(&names(&["bob", "alice", "bob"])),
+ vec![("alice".to_owned(), true), ("bob".to_owned(), true)]
);
// Without bootstrap users, no registry.
- assert!(first_users(&[], &names(&["alice"])).is_empty());
+ assert!(first_users(&[]).is_empty());
let admin = Caps::new(
first_caps(true)
.into_iter()