[−][src]Struct casbin::Enforcer
Enforcer is the main interface for authorization enforcement and policy management.
Methods
impl Enforcer
[src]
pub fn new(m: Model, a: Box<dyn Adapter>) -> Result<Self>
[src]
Enforcer::new creates an enforcer via file or DB.
pub fn add_function(&mut self, fname: &str, f: fn(_: String, _: String) -> bool)
[src]
pub fn get_model(&self) -> &Model
[src]
pub fn get_mut_model(&mut self) -> &mut Model
[src]
pub fn set_watcher(&mut self, w: Box<dyn Watcher>)
[src]
pub fn enforce(&self, rvals: Vec<&str>) -> Result<bool>
[src]
Enforce decides whether a "subject" can access a "object" with the operation "action", input parameters are usually: (sub, obj, act).
Examples
use casbin::{Enforcer, Model, FileAdapter}; let m = Model::from_file("examples/basic_model.conf").unwrap(); let adapter = FileAdapter::new("examples/basic_policy.csv"); let e = Enforcer::new(m, Box::new( adapter)).unwrap(); assert_eq!(true, e.enforce(vec!["alice", "data1", "read"]).unwrap());
pub fn build_role_links(&mut self) -> Result<()>
[src]
pub fn load_policy(&mut self) -> Result<()>
[src]
pub fn clear_policy(&mut self)
[src]
pub fn enable_auto_save(&mut self, auto_save: bool)
[src]
pub fn enable_auto_build_role_links(&mut self, auto_build_role_links: bool)
[src]
Trait Implementations
impl InternalApi for Enforcer
[src]
fn add_policy_internal(
&mut self,
sec: &str,
ptype: &str,
rule: Vec<&str>
) -> Result<bool>
[src]
&mut self,
sec: &str,
ptype: &str,
rule: Vec<&str>
) -> Result<bool>
fn remove_policy_internal(
&mut self,
sec: &str,
ptype: &str,
rule: Vec<&str>
) -> Result<bool>
[src]
&mut self,
sec: &str,
ptype: &str,
rule: Vec<&str>
) -> Result<bool>
fn remove_filtered_policy_internal(
&mut self,
sec: &str,
ptype: &str,
field_index: usize,
field_values: Vec<&str>
) -> Result<bool>
[src]
&mut self,
sec: &str,
ptype: &str,
field_index: usize,
field_values: Vec<&str>
) -> Result<bool>
impl MgmtApi for Enforcer
[src]
fn add_policy(&mut self, params: Vec<&str>) -> Result<bool>
[src]
fn remove_policy(&mut self, params: Vec<&str>) -> Result<bool>
[src]
fn add_named_policy(&mut self, ptype: &str, params: Vec<&str>) -> Result<bool>
[src]
fn remove_named_policy(
&mut self,
ptype: &str,
params: Vec<&str>
) -> Result<bool>
[src]
&mut self,
ptype: &str,
params: Vec<&str>
) -> Result<bool>
fn add_grouping_policy(&mut self, params: Vec<&str>) -> Result<bool>
[src]
fn add_named_grouping_policy(
&mut self,
ptype: &str,
params: Vec<&str>
) -> Result<bool>
[src]
&mut self,
ptype: &str,
params: Vec<&str>
) -> Result<bool>
fn remove_grouping_policy(&mut self, params: Vec<&str>) -> Result<bool>
[src]
fn remove_named_grouping_policy(
&mut self,
ptype: &str,
params: Vec<&str>
) -> Result<bool>
[src]
&mut self,
ptype: &str,
params: Vec<&str>
) -> Result<bool>
fn remove_filtered_grouping_policy(
&mut self,
field_index: usize,
field_values: Vec<&str>
) -> Result<bool>
[src]
&mut self,
field_index: usize,
field_values: Vec<&str>
) -> Result<bool>
fn remove_filtered_named_grouping_policy(
&mut self,
ptype: &str,
field_index: usize,
field_values: Vec<&str>
) -> Result<bool>
[src]
&mut self,
ptype: &str,
field_index: usize,
field_values: Vec<&str>
) -> Result<bool>
fn remove_filtered_policy(
&mut self,
field_index: usize,
field_values: Vec<&str>
) -> Result<bool>
[src]
&mut self,
field_index: usize,
field_values: Vec<&str>
) -> Result<bool>
fn remove_filtered_named_policy(
&mut self,
ptype: &str,
field_index: usize,
field_values: Vec<&str>
) -> Result<bool>
[src]
&mut self,
ptype: &str,
field_index: usize,
field_values: Vec<&str>
) -> Result<bool>
fn get_policy(&self) -> Vec<Vec<String>>
[src]
fn get_named_policy(&self, ptype: &str) -> Vec<Vec<String>>
[src]
fn get_filtered_policy(
&self,
field_index: usize,
field_values: Vec<&str>
) -> Vec<Vec<String>>
[src]
&self,
field_index: usize,
field_values: Vec<&str>
) -> Vec<Vec<String>>
fn get_filtered_named_policy(
&self,
ptype: &str,
field_index: usize,
field_values: Vec<&str>
) -> Vec<Vec<String>>
[src]
&self,
ptype: &str,
field_index: usize,
field_values: Vec<&str>
) -> Vec<Vec<String>>
fn has_policy(&self, params: Vec<&str>) -> bool
[src]
fn has_named_policy(&self, ptype: &str, params: Vec<&str>) -> bool
[src]
fn get_grouping_policy(&self) -> Vec<Vec<String>>
[src]
fn get_named_grouping_policy(&self, ptype: &str) -> Vec<Vec<String>>
[src]
fn get_filtered_grouping_policy(
&self,
field_index: usize,
field_values: Vec<&str>
) -> Vec<Vec<String>>
[src]
&self,
field_index: usize,
field_values: Vec<&str>
) -> Vec<Vec<String>>
fn get_filtered_named_grouping_policy(
&self,
ptype: &str,
field_index: usize,
field_values: Vec<&str>
) -> Vec<Vec<String>>
[src]
&self,
ptype: &str,
field_index: usize,
field_values: Vec<&str>
) -> Vec<Vec<String>>
fn has_grouping_policy(&self, params: Vec<&str>) -> bool
[src]
fn has_grouping_named_policy(&self, ptype: &str, params: Vec<&str>) -> bool
[src]
fn get_all_subjects(&self) -> Vec<String>
[src]
fn get_all_named_subjects(&self, ptype: &str) -> Vec<String>
[src]
fn get_all_objects(&self) -> Vec<String>
[src]
fn get_all_named_objects(&self, ptype: &str) -> Vec<String>
[src]
fn get_all_actions(&self) -> Vec<String>
[src]
fn get_all_named_actions(&self, ptype: &str) -> Vec<String>
[src]
fn get_all_roles(&self) -> Vec<String>
[src]
fn get_all_named_roles(&self, ptype: &str) -> Vec<String>
[src]
impl RbacApi for Enforcer
[src]
fn add_permission_for_user(
&mut self,
user: &str,
permission: Vec<&str>
) -> Result<bool>
[src]
&mut self,
user: &str,
permission: Vec<&str>
) -> Result<bool>
fn add_role_for_user(
&mut self,
user: &str,
role: &str,
domain: Option<&str>
) -> Result<bool>
[src]
&mut self,
user: &str,
role: &str,
domain: Option<&str>
) -> Result<bool>
fn delete_role_for_user(
&mut self,
user: &str,
role: &str,
domain: Option<&str>
) -> Result<bool>
[src]
&mut self,
user: &str,
role: &str,
domain: Option<&str>
) -> Result<bool>
fn delete_roles_for_user(
&mut self,
user: &str,
domain: Option<&str>
) -> Result<bool>
[src]
&mut self,
user: &str,
domain: Option<&str>
) -> Result<bool>
fn get_roles_for_user(
&mut self,
name: &str,
domain: Option<&str>
) -> Vec<String>
[src]
&mut self,
name: &str,
domain: Option<&str>
) -> Vec<String>
fn get_users_for_role(&self, name: &str, domain: Option<&str>) -> Vec<String>
[src]
fn has_role_for_user(
&mut self,
name: &str,
role: &str,
domain: Option<&str>
) -> bool
[src]
&mut self,
name: &str,
role: &str,
domain: Option<&str>
) -> bool
fn delete_user(&mut self, name: &str) -> Result<bool>
[src]
fn delete_role(&mut self, name: &str) -> Result<bool>
[src]
fn delete_permission(&mut self, permission: Vec<&str>) -> Result<bool>
[src]
fn delete_permission_for_user(
&mut self,
user: &str,
permission: Vec<&str>
) -> Result<bool>
[src]
&mut self,
user: &str,
permission: Vec<&str>
) -> Result<bool>
fn delete_permissions_for_user(&mut self, user: &str) -> Result<bool>
[src]
fn get_permissions_for_user(
&self,
user: &str,
domain: Option<&str>
) -> Vec<Vec<String>>
[src]
&self,
user: &str,
domain: Option<&str>
) -> Vec<Vec<String>>
fn has_permission_for_user(&self, user: &str, permission: Vec<&str>) -> bool
[src]
fn get_implicit_roles_for_user(
&mut self,
name: &str,
domain: Option<&str>
) -> Vec<String>
[src]
&mut self,
name: &str,
domain: Option<&str>
) -> Vec<String>
fn get_implicit_permissions_for_user(
&mut self,
user: &str,
domain: Option<&str>
) -> Vec<Vec<String>>
[src]
&mut self,
user: &str,
domain: Option<&str>
) -> Vec<Vec<String>>
fn get_implicit_users_for_permission(
&self,
permission: Vec<&str>
) -> Vec<String>
[src]
&self,
permission: Vec<&str>
) -> Vec<String>
Auto Trait Implementations
impl !RefUnwindSafe for Enforcer
impl Send for Enforcer
impl Sync for Enforcer
impl Unpin for Enforcer
impl !UnwindSafe for Enforcer
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,