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/swarm/bootstrap.rs | |
| parent | 4479bb89595958721a2dfef57dbcb89b255a7ad8 (diff) | |
access first usersauth
Diffstat (limited to 'src/swarm/bootstrap.rs')
| -rw-r--r-- | src/swarm/bootstrap.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/swarm/bootstrap.rs b/src/swarm/bootstrap.rs index 76e056d..a7266c7 100644 --- a/src/swarm/bootstrap.rs +++ b/src/swarm/bootstrap.rs @@ -91,8 +91,28 @@ pub(crate) async fn bootstrap(state: &AppState, seeds: &[String], start: Start) // Plain names (kebab-case): serializing them can't fail. let topology = serde_json::to_value(state.configured_ways.0).unwrap_or_default(); let dissemination = serde_json::to_value(state.configured_ways.1).unwrap_or_default(); + // The first users, granted by this node: with the rest, so that no node sees the + // swarm without its registry (none named: none, as in a swarm from before). + let (by, since) = ( + state.local_id().to_owned(), + state.clock.now_millis().as_u64(), + ); + let users: Vec<(Vec<String>, JsonValue)> = state + .first_users + .iter() + .map(|(name, admin)| { + let caps = crate::access::registry::first_caps(*admin); + ( + crate::access::registry::user_path(name), + crate::access::registry::entry(&by, since, &caps), + ) + }) + .collect(); state .mutate_doc(move |doc| { + for (path, entry) in &users { + store::write_path(doc, path, entry)?; + } store::write_path(doc, &swarm_id_path(), &recorded)?; store::write_path( doc, @@ -107,7 +127,9 @@ pub(crate) async fn bootstrap(state: &AppState, seeds: &[String], start: Start) ) }) .await - .context("Recording the swarm ID, its neighbours, its topology and dissemination")?; + .context( + "Recording the swarm ID, its neighbours, its topology and dissemination, its first users", + )?; state.initial_sync_done.store(true, Ordering::Release); state.mark_ready(swarm_id).await?; // Remembered members, if any, to find those still running. |
