diff --git a/Cargo.toml b/Cargo.toml index 8869f94..da8843a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-casbin" -version = "0.3.1" +version = "0.3.2" authors = ["Eason Chai ","Cheng JIANG "] edition = "2018" license = "Apache-2.0" diff --git a/README.md b/README.md index 1c0b466..1f67470 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Add it to `Cargo.toml` ```rust -actix-casbin = "0.3.1" +actix-casbin = "0.3.2" actix-rt = "1.1.1" ``` diff --git a/src/casbin_actor.rs b/src/casbin_actor.rs index 4c190b3..a237388 100644 --- a/src/casbin_actor.rs +++ b/src/casbin_actor.rs @@ -14,6 +14,12 @@ pub enum CasbinCmd { Enforce(Vec), AddPolicy(Vec), AddPolicies(Vec>), + AddNamedPolicy(String, Vec), + AddNamedPolicies(String, Vec>), + AddGroupingPolicy(Vec), + AddGroupingPolicies(Vec>), + AddNamedGroupingPolicy(String, Vec), + AddNamedGroupingPolicies(String, Vec>), RemovePolicy(Vec), RemovePolicies(Vec>), RemoveFilteredPolicy(usize, Vec), @@ -29,6 +35,12 @@ pub enum CasbinResult { Enforce(bool), AddPolicy(bool), AddPolicies(bool), + AddNamedPolicy(bool), + AddNamedPolicies(bool), + AddGroupingPolicy(bool), + AddGroupingPolicies(bool), + AddNamedGroupingPolicy(bool), + AddNamedGroupingPolicies(bool), RemovePolicy(bool), RemovePolicies(bool), RemoveFilteredPolicy(bool), @@ -104,6 +116,30 @@ impl Handler for CasbinActor { .add_policies(policy) .await .map(CasbinResult::AddPolicies), + CasbinCmd::AddNamedPolicy(ptype, policy) => lock + .add_named_policy(&ptype, policy) + .await + .map(CasbinResult::AddNamedPolicy), + CasbinCmd::AddNamedPolicies(ptype, policy) => lock + .add_named_policies(&ptype, policy) + .await + .map(CasbinResult::AddNamedPolicies), + CasbinCmd::AddGroupingPolicy(policy) => lock + .add_grouping_policy(policy) + .await + .map(CasbinResult::AddGroupingPolicy), + CasbinCmd::AddGroupingPolicies(policy) => lock + .add_grouping_policies(policy) + .await + .map(CasbinResult::AddGroupingPolicies), + CasbinCmd::AddNamedGroupingPolicy(ptype, policy) => lock + .add_named_grouping_policy(&ptype, policy) + .await + .map(CasbinResult::AddNamedGroupingPolicy), + CasbinCmd::AddNamedGroupingPolicies(ptype, policy) => lock + .add_named_grouping_policies(&ptype, policy) + .await + .map(CasbinResult::AddNamedGroupingPolicies), CasbinCmd::RemovePolicy(policy) => lock .remove_policy(policy) .await