pub struct ACL { /* private fields */ }Expand description
Access control list manager.
Thread safety: Rust’s borrow checker enforces exclusive access for mutation (&mut self for add_rule/remove_rule/reload). The check() method takes &self and is safe for concurrent reads. No internal lock is needed.
Implementations§
Source§impl ACL
impl ACL
Sourcepub fn new(rules: Vec<ACLRule>, default_effect: impl Into<String>) -> ACL
pub fn new(rules: Vec<ACLRule>, default_effect: impl Into<String>) -> ACL
Create a new ACL with the given rules and default effect.
Sourcepub fn set_audit_logger(
&mut self,
logger: impl Fn(&AuditEntry) + Send + Sync + 'static,
)
pub fn set_audit_logger( &mut self, logger: impl Fn(&AuditEntry) + Send + Sync + 'static, )
Set the audit logger callback.
Sourcepub fn add_rule(&mut self, rule: ACLRule) -> Result<(), ModuleError>
pub fn add_rule(&mut self, rule: ACLRule) -> Result<(), ModuleError>
Add a rule to the ACL (inserted at position 0, highest priority).
Sourcepub fn remove_rule(&mut self, callers: &[String], targets: &[String]) -> bool
pub fn remove_rule(&mut self, callers: &[String], targets: &[String]) -> bool
Remove the first rule matching the given callers and targets. Returns true if a rule was removed.
Sourcepub fn check(
&self,
caller_id: Option<&str>,
target_id: &str,
ctx: Option<&Context<Value>>,
) -> Result<bool, ModuleError>
pub fn check( &self, caller_id: Option<&str>, target_id: &str, ctx: Option<&Context<Value>>, ) -> Result<bool, ModuleError>
Check whether the given caller is allowed to access the target.
Uses first-match-wins evaluation. Maps None caller to @external.
Sourcepub fn reload(&mut self) -> Result<(), ModuleError>
pub fn reload(&mut self) -> Result<(), ModuleError>
Reload rules from the stored YAML path.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ACL
impl !RefUnwindSafe for ACL
impl Send for ACL
impl Sync for ACL
impl Unpin for ACL
impl UnsafeUnpin for ACL
impl !UnwindSafe for ACL
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more