aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/access.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
commitf2487f5a1f897bb5499ffd782562f53967f20606 (patch)
tree3e6b64f4ef1ebe1c19e346c2080a5a7afb31ec26 /src/api/access.rs
parentc82a62186a8e0a46fd41e08345a2fa3e54ddffe2 (diff)
access: keeping the swarm manageable
A write that would leave its own writer unable to manage users (deleting, disabling or narrowing its entry, removing the registry) is refused; --protocol-writers can set a registry right that nobody may manage any more. Auth plan M1.
Diffstat (limited to 'src/api/access.rs')
-rw-r--r--src/api/access.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/api/access.rs b/src/api/access.rs
index 8a3e630..ade6542 100644
--- a/src/api/access.rs
+++ b/src/api/access.rs
@@ -9,7 +9,7 @@ use axum::{
response::Response,
};
use serde_json::Value as JsonValue;
-use tracing::debug;
+use tracing::{debug, warn};
use super::auth::AuthenticatedUser;
use super::error_response;
@@ -194,6 +194,13 @@ pub(crate) async fn authorize(
let replica = state.doc.read().await;
if !registry::exists(&replica.doc) {
Access::Everything
+ } else if state.protocol_writers.contains(&user)
+ && registry::managers(&replica.doc).is_empty()
+ {
+ // Nobody may manage users any more (two removals at once, merged; or an
+ // entry damaged): this node's protocol writers may set it right.
+ warn!(user = %user, "The user registry has nobody who may manage users; a protocol writer may do everything until it has");
+ Access::Everything
} else {
match registry::user(&replica.doc, &user) {
Some(entry) => Access::Caps(entry.caps()),