aboutsummaryrefslogtreecommitdiffstats
path: root/src/access/mod.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-09 22:24:45 +0000
committertv <tv@krebsco.de>2026-11-11 23:28:25 +0100
commit925f566990fdd4043df691b3277a2a50b937ec1b (patch)
tree067c9339ba45d10206763357e5eed38921293527 /src/access/mod.rs
parenta0c8fcb2693cc017d78e39a6e623d1c53e493a84 (diff)
access: a limit that meets none of the user's capabilities gives nothing to look with
Looking at a node (its figures, peers, dashboard: Need::Observe) takes any capability, a token's limit applied. Caps::is_empty is now true where no capability of the user meets one of the limit's (Capability::meet), as well as where there are none: a token limited to the member list, for a user who may only read data/eu, may not look.
Diffstat (limited to 'src/access/mod.rs')
-rw-r--r--src/access/mod.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/access/mod.rs b/src/access/mod.rs
index ad50c72..cc6b7a2 100644
--- a/src/access/mod.rs
+++ b/src/access/mod.rs
@@ -197,8 +197,16 @@ impl Caps {
self.limit.is_some()
}
+ /// Whether they give nothing: none at all, or none that a token's limit meets
+ /// somewhere (`Capability::meet`).
pub(crate) fn is_empty(&self) -> bool {
- self.caps.is_empty() || self.limit.as_ref().is_some_and(Vec::is_empty)
+ match &self.limit {
+ None => self.caps.is_empty(),
+ Some(limit) => !self
+ .caps
+ .iter()
+ .any(|cap| limit.iter().any(|outer| cap.meet(outer).is_some())),
+ }
}
}