MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / effective_scopes

Method effective_scopes

nodedb/src/control/security/scope/grant.rs:266–285  ·  view source on GitHub ↗

Resolve effective scopes for a user. Collects: user's direct scopes + org scopes for each org membership. Filters out expired grants.

(&self, user_id: &str, org_ids: &[String])

Source from the content-addressed store, hash-verified

264 /// Collects: user's direct scopes + org scopes for each org membership.
265 /// Filters out expired grants.
266 pub fn effective_scopes(&self, user_id: &str, org_ids: &[String]) -> HashSet<String> {
267 let grants = self.grants.read().unwrap_or_else(|p| p.into_inner());
268 let mut effective = HashSet::new();
269
270 for g in grants.values() {
271 if !g.is_effective() {
272 continue; // Skip expired grants.
273 }
274 // Direct user grant.
275 if g.grantee_type == "user" && g.grantee_id == user_id {
276 effective.insert(g.scope_name.clone());
277 }
278 // Org grant (user inherits via membership).
279 if g.grantee_type == "org" && org_ids.contains(&g.grantee_id) {
280 effective.insert(g.scope_name.clone());
281 }
282 }
283
284 effective
285 }
286
287 /// Check if a user (directly or via orgs) has a specific scope.
288 pub fn has_scope(&self, user_id: &str, org_ids: &[String], scope_name: &str) -> bool {

Callers 7

explain_permissionFunction · 0.80
has_scopeMethod · 0.80
effective_scopes_unionFunction · 0.80
explain_scopeFunction · 0.80
show_my_scopesFunction · 0.80
show_scopes_forFunction · 0.80

Calls 5

is_effectiveMethod · 0.80
readMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45
containsMethod · 0.45

Tested by 1

effective_scopes_unionFunction · 0.64