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

Method check_write_with_auth

nodedb/src/control/security/rls/eval.rs:65–91  ·  view source on GitHub ↗

Write-path RLS check with `$auth.*` support. Evaluates compiled write policies; fail-closed on unresolved auth references. Emits `AuditEvent::RlsRejected` via `emitter` on every denial.

(
        &self,
        tenant_id: u64,
        collection: &str,
        document: &serde_json::Value,
        auth: &AuthContext,
        emitter: &dyn AuditEmitter,
    )

Source from the content-addressed store, hash-verified

63 ///
64 /// Emits `AuditEvent::RlsRejected` via `emitter` on every denial.
65 pub fn check_write_with_auth(
66 &self,
67 tenant_id: u64,
68 collection: &str,
69 document: &serde_json::Value,
70 auth: &AuthContext,
71 emitter: &dyn AuditEmitter,
72 ) -> crate::Result<()> {
73 if auth.is_superuser() {
74 return Ok(());
75 }
76
77 let policies = self.write_policies(tenant_id, collection);
78 if policies.is_empty() {
79 return Ok(());
80 }
81
82 for policy in &policies {
83 if let Some(ref compiled) = policy.compiled_predicate {
84 check_compiled_write(
85 policy, compiled, document, auth, tenant_id, collection, emitter,
86 )?;
87 }
88 }
89
90 Ok(())
91 }
92}
93
94fn check_compiled_write(

Calls 4

check_compiled_writeFunction · 0.85
is_superuserMethod · 0.80
write_policiesMethod · 0.80
is_emptyMethod · 0.45