Files
filestash/server/plugin/plg_runtime_cookbook/authorisation/lib.rs
T

29 lines
677 B
Rust

use filestash::*;
#[derive(Default)]
pub struct Plugin;
impl Authorisation for Plugin {
fn ls(&self, _ctx: &impl Context, path: &str) -> Decision {
self.check(path)
}
fn cat(&self, _ctx: &impl Context, path: &str) -> Decision {
self.check(path)
}
fn stat(&self, _ctx: &impl Context, path: &str) -> Decision {
self.check(path)
}
}
impl Plugin {
fn check(&self, path: &str) -> Decision {
if path.split("/").any(|segment| segment == "top_secret") {
log::warn!("[TOPSECRET] access denied !!");
return Decision::Deny;
}
Decision::Allow
}
}
register!(Plugin: Authorisation);