Class: Casbin::ManagementEnforcer
- Inherits:
-
InternalEnforcer
- Object
- CoreEnforcer
- InternalEnforcer
- Casbin::ManagementEnforcer
- Defined in:
- lib/casbin-ruby/management_enforcer.rb
Overview
ManagementEnforcer = InternalEnforcer + Management API.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from CoreEnforcer
#adapter, #auto_build_role_links, #auto_save, #effector, #enabled, #model, #rm_map, #watcher
Instance Method Summary collapse
-
#add_function(name, func) ⇒ Object
adds a customized function.
-
#add_grouping_policies(rules) ⇒ Object
adds role inheritance rulea to the current policy.
-
#add_grouping_policy(*params) ⇒ Object
adds a role inheritance rule to the current policy.
-
#add_named_grouping_policies(ptype, rules) ⇒ Object
adds named role inheritance rules to the current policy.
-
#add_named_grouping_policy(ptype, *params) ⇒ Object
adds a named role inheritance rule to the current policy.
-
#add_named_policies(ptype, rules) ⇒ Object
adds authorization rules to the current named policy.
-
#add_named_policy(ptype, *params) ⇒ Object
adds an authorization rule to the current named policy.
-
#add_policies(rules) ⇒ Object
adds authorization rules to the current policy.
-
#add_policy(*params) ⇒ Object
adds an authorization rule to the current policy.
-
#get_all_actions ⇒ Object
gets the list of actions that show up in the current policy.
-
#get_all_named_actions(ptype) ⇒ Object
gets the list of actions that show up in the current named policy.
-
#get_all_named_objects(ptype) ⇒ Object
gets the list of objects that show up in the current named policy.
- #get_all_named_roles(ptype) ⇒ Object
-
#get_all_named_subjects(ptype) ⇒ Object
gets the list of subjects that show up in the current named policy.
-
#get_all_objects ⇒ Object
gets the list of objects that show up in the current policy.
-
#get_all_roles ⇒ Object
gets the list of roles that show up in the current named policy.
-
#get_all_subjects ⇒ Object
gets the list of subjects that show up in the current policy.
-
#get_filtered_grouping_policy(field_index, *field_values) ⇒ Object
gets all the role inheritance rules in the policy, field filters can be specified.
-
#get_filtered_named_grouping_policy(ptype, field_index, *field_values) ⇒ Object
gets all the role inheritance rules in the policy, field filters can be specified.
-
#get_filtered_named_policy(ptype, field_index, *field_values) ⇒ Object
gets all the authorization rules in the named policy, field filters can be specified.
-
#get_filtered_policy(field_index, *field_values) ⇒ Object
gets all the authorization rules in the policy, field filters can be specified.
-
#get_grouping_policy ⇒ Object
gets all the role inheritance rules in the policy.
-
#get_named_grouping_policy(ptype) ⇒ Object
gets all the role inheritance rules in the policy.
-
#get_named_policy(ptype) ⇒ Object
gets all the authorization rules in the named policy.
-
#get_policy ⇒ Object
gets all the authorization rules in the policy.
-
#has_grouping_policy ⇒ Object
determines whether a role inheritance rule exists.
-
#has_named_grouping_policy(ptype, *params) ⇒ Object
determines whether a named role inheritance rule exists.
-
#has_named_policy(ptype, *params) ⇒ Object
determines whether a named authorization rule exists.
-
#has_policy(*params) ⇒ Object
determines whether an authorization rule exists.
- #parent_add_policies ⇒ Object
- #parent_add_policy ⇒ Object
- #parent_remove_filtered_policy ⇒ Object
- #parent_remove_policies ⇒ Object
- #parent_remove_policy ⇒ Object
- #parent_update_policies ⇒ Object
- #parent_update_policy ⇒ Object
-
#remove_filtered_grouping_policy(field_index, *field_values) ⇒ Object
removes a role inheritance rule from the current policy, field filters can be specified.
-
#remove_filtered_named_grouping_policy(ptype, field_index, *field_values) ⇒ Object
removes a role inheritance rule from the current named policy, field filters can be specified.
-
#remove_filtered_named_policy(ptype, field_index, *field_values) ⇒ Object
removes an authorization rule from the current named policy, field filters can be specified.
-
#remove_filtered_policy(field_index, *field_values) ⇒ Object
removes an authorization rule from the current policy, field filters can be specified.
-
#remove_grouping_policies(rules) ⇒ Object
removes role inheritance rulea from the current policy.
-
#remove_grouping_policy(*params) ⇒ Object
removes a role inheritance rule from the current policy.
-
#remove_named_grouping_policies(ptype, rules) ⇒ Object
removes role inheritance rules from the current named policy.
-
#remove_named_grouping_policy(ptype, *params) ⇒ Object
removes a role inheritance rule from the current named policy.
-
#remove_named_policies(ptype, rules) ⇒ Object
removes authorization rules from the current named policy.
-
#remove_named_policy(ptype, *params) ⇒ Object
removes an authorization rule from the current named policy.
-
#remove_policies(rules) ⇒ Object
removes authorization rules from the current policy.
-
#remove_policy(*params) ⇒ Object
removes an authorization rule from the current policy.
-
#update_named_policies(ptype, old_rules, new_rules) ⇒ Object
updates authorization rules from the current named policy.
-
#update_named_policy(ptype, old_rule, new_rule) ⇒ Object
updates an authorization rule from the current named policy.
-
#update_policies(old_rules, new_rules) ⇒ Object
updates authorization rules from the current policy.
-
#update_policy(old_rule, new_rule) ⇒ Object
updates an authorization rule from the current policy.
Methods inherited from CoreEnforcer
#add_named_domain_matching_func, #add_named_matching_func, #build_role_links, #clear_policy, #enable_auto_build_role_links, #enable_auto_save, #enable_enforce, #enforce, #enforce_ex, #filtered?, #init_with_adapter, #init_with_file, #init_with_model_and_adapter, #initialize, #load_filtered_policy, #load_increment_filtered_policy, #load_model, #load_policy, #new_model, new_model, #role_manager, #role_manager=, #save_policy
Constructor Details
This class inherits a constructor from Casbin::CoreEnforcer
Instance Method Details
#add_function(name, func) ⇒ Object
adds a customized function.
293 294 295 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 293 def add_function(name, func) fm.add_function(name, func) end |
#add_grouping_policies(rules) ⇒ Object
adds role inheritance rulea to the current policy.
If the rule already exists, the function returns false for the corresponding policy rule and the rule will not be added. Otherwise the function returns true for the corresponding policy rule by adding the new rule.
226 227 228 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 226 def add_grouping_policies(rules) add_named_grouping_policies('g', rules) end |
#add_grouping_policy(*params) ⇒ Object
adds a role inheritance rule to the current policy.
If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.
217 218 219 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 217 def add_grouping_policy(*params) add_named_grouping_policy('g', *params) end |
#add_named_grouping_policies(ptype, rules) ⇒ Object
adds named role inheritance rules to the current policy.
If the rule already exists, the function returns false for the corresponding policy rule and the rule will not be added. Otherwise the function returns true for the corresponding policy rule by adding the new rule.
249 250 251 252 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 249 def add_named_grouping_policies(ptype, rules) rules_added = parent_add_policies('g', ptype, rules) auto_build_role_links ? build_role_links : rules_added end |
#add_named_grouping_policy(ptype, *params) ⇒ Object
adds a named role inheritance rule to the current policy.
If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.
234 235 236 237 238 239 240 241 242 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 234 def add_named_grouping_policy(ptype, *params) rule_added = if params.size == 1 && params[0].is_a?(Array) parent_add_policy('g', ptype, params[0]) else parent_add_policy('g', ptype, params) end auto_build_role_links ? build_role_links : rule_added end |
#add_named_policies(ptype, rules) ⇒ Object
adds authorization rules to the current named policy.
If the rule already exists, the function returns false for the corresponding rule and the rule will not be added. Otherwise the function returns true for the corresponding by adding the new rule.
141 142 143 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 141 def add_named_policies(ptype, rules) parent_add_policies('p', ptype, rules) end |
#add_named_policy(ptype, *params) ⇒ Object
adds an authorization rule to the current named policy.
If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.
129 130 131 132 133 134 135 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 129 def add_named_policy(ptype, *params) if params.size == 1 && params[0].is_a?(Array) parent_add_policy('p', ptype, params[0]) else parent_add_policy('p', ptype, params) end end |
#add_policies(rules) ⇒ Object
adds authorization rules to the current policy.
If the rule already exists, the function returns false for the corresponding rule and the rule will not be added. Otherwise the function returns true for the corresponding rule by adding the new rule.
121 122 123 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 121 def add_policies(rules) add_named_policies('p', rules) end |
#add_policy(*params) ⇒ Object
adds an authorization rule to the current policy.
If the rule already exists, the function returns false and the rule will not be added. Otherwise the function returns true by adding the new rule.
113 114 115 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 113 def add_policy(*params) add_named_policy('p', *params) end |
#get_all_actions ⇒ Object
gets the list of actions that show up in the current policy.
37 38 39 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 37 def get_all_actions get_all_named_actions('p') end |
#get_all_named_actions(ptype) ⇒ Object
gets the list of actions that show up in the current named policy.
42 43 44 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 42 def get_all_named_actions(ptype) model.get_values_for_field_in_policy('p', ptype, 2) end |
#get_all_named_objects(ptype) ⇒ Object
gets the list of objects that show up in the current named policy.
32 33 34 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 32 def get_all_named_objects(ptype) model.get_values_for_field_in_policy('p', ptype, 1) end |
#get_all_named_roles(ptype) ⇒ Object
51 52 53 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 51 def get_all_named_roles(ptype) model.get_values_for_field_in_policy('g', ptype, 1) end |
#get_all_named_subjects(ptype) ⇒ Object
gets the list of subjects that show up in the current named policy.
22 23 24 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 22 def get_all_named_subjects(ptype) model.get_values_for_field_in_policy('p', ptype, 0) end |
#get_all_objects ⇒ Object
gets the list of objects that show up in the current policy.
27 28 29 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 27 def get_all_objects get_all_named_objects('p') end |
#get_all_roles ⇒ Object
gets the list of roles that show up in the current named policy.
47 48 49 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 47 def get_all_roles get_all_named_roles('g') end |
#get_all_subjects ⇒ Object
gets the list of subjects that show up in the current policy.
17 18 19 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 17 def get_all_subjects get_all_named_subjects('p') end |
#get_filtered_grouping_policy(field_index, *field_values) ⇒ Object
gets all the role inheritance rules in the policy, field filters can be specified.
81 82 83 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 81 def get_filtered_grouping_policy(field_index, *field_values) get_filtered_named_grouping_policy('g', field_index, *field_values) end |
#get_filtered_named_grouping_policy(ptype, field_index, *field_values) ⇒ Object
gets all the role inheritance rules in the policy, field filters can be specified.
91 92 93 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 91 def get_filtered_named_grouping_policy(ptype, field_index, *field_values) model.get_filtered_policy('g', ptype, field_index, *field_values) end |
#get_filtered_named_policy(ptype, field_index, *field_values) ⇒ Object
gets all the authorization rules in the named policy, field filters can be specified.
71 72 73 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 71 def get_filtered_named_policy(ptype, field_index, *field_values) model.get_filtered_policy('p', ptype, field_index, *field_values) end |
#get_filtered_policy(field_index, *field_values) ⇒ Object
gets all the authorization rules in the policy, field filters can be specified.
61 62 63 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 61 def get_filtered_policy(field_index, *field_values) get_filtered_named_policy('p', field_index, *field_values) end |
#get_grouping_policy ⇒ Object
gets all the role inheritance rules in the policy.
76 77 78 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 76 def get_grouping_policy get_named_grouping_policy('g') end |
#get_named_grouping_policy(ptype) ⇒ Object
gets all the role inheritance rules in the policy.
86 87 88 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 86 def get_named_grouping_policy(ptype) model.get_policy('g', ptype) end |
#get_named_policy(ptype) ⇒ Object
gets all the authorization rules in the named policy.
66 67 68 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 66 def get_named_policy(ptype) model.get_policy('p', ptype) end |
#get_policy ⇒ Object
gets all the authorization rules in the policy.
56 57 58 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 56 def get_policy get_named_policy('p') end |
#has_grouping_policy ⇒ Object
determines whether a role inheritance rule exists.
200 201 202 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 200 def has_grouping_policy has_named_grouping_policy('g', *params) end |
#has_named_grouping_policy(ptype, *params) ⇒ Object
determines whether a named role inheritance rule exists.
205 206 207 208 209 210 211 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 205 def has_named_grouping_policy(ptype, *params) if params.size == 1 && params[0].is_a?(Array) model.has_policy('g', ptype, params[0]) else model.has_policy('g', ptype, params) end end |
#has_named_policy(ptype, *params) ⇒ Object
determines whether a named authorization rule exists.
101 102 103 104 105 106 107 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 101 def has_named_policy(ptype, *params) if params.size == 1 && params[0].is_a?(Array) model.has_policy('p', ptype, params[0]) else model.has_policy('p', ptype, params) end end |
#has_policy(*params) ⇒ Object
determines whether an authorization rule exists.
96 97 98 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 96 def has_policy(*params) has_named_policy('p', *params) end |
#parent_add_policies ⇒ Object
9 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 9 alias parent_add_policies add_policies |
#parent_add_policy ⇒ Object
8 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 8 alias parent_add_policy add_policy |
#parent_remove_filtered_policy ⇒ Object
14 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 14 alias parent_remove_filtered_policy remove_filtered_policy |
#parent_remove_policies ⇒ Object
13 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 13 alias parent_remove_policies remove_policies |
#parent_remove_policy ⇒ Object
12 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 12 alias parent_remove_policy remove_policy |
#parent_update_policies ⇒ Object
11 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 11 alias parent_update_policies update_policies |
#parent_update_policy ⇒ Object
10 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 10 alias parent_update_policy update_policy |
#remove_filtered_grouping_policy(field_index, *field_values) ⇒ Object
removes a role inheritance rule from the current policy, field filters can be specified.
265 266 267 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 265 def remove_filtered_grouping_policy(field_index, *field_values) remove_filtered_named_grouping_policy('g', field_index, *field_values) end |
#remove_filtered_named_grouping_policy(ptype, field_index, *field_values) ⇒ Object
removes a role inheritance rule from the current named policy, field filters can be specified.
287 288 289 290 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 287 def remove_filtered_named_grouping_policy(ptype, field_index, *field_values) rule_removed = parent_remove_filtered_policy('g', ptype, field_index, *field_values) auto_build_role_links ? build_role_links : rule_removed end |
#remove_filtered_named_policy(ptype, field_index, *field_values) ⇒ Object
removes an authorization rule from the current named policy, field filters can be specified.
195 196 197 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 195 def remove_filtered_named_policy(ptype, field_index, *field_values) parent_remove_filtered_policy('p', ptype, field_index, *field_values) end |
#remove_filtered_policy(field_index, *field_values) ⇒ Object
removes an authorization rule from the current policy, field filters can be specified.
176 177 178 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 176 def remove_filtered_policy(field_index, *field_values) remove_filtered_named_policy('p', field_index, *field_values) end |
#remove_grouping_policies(rules) ⇒ Object
removes role inheritance rulea from the current policy.
260 261 262 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 260 def remove_grouping_policies(rules) remove_named_grouping_policies('g', rules) end |
#remove_grouping_policy(*params) ⇒ Object
removes a role inheritance rule from the current policy.
255 256 257 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 255 def remove_grouping_policy(*params) remove_named_grouping_policy('g', *params) end |
#remove_named_grouping_policies(ptype, rules) ⇒ Object
removes role inheritance rules from the current named policy.
281 282 283 284 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 281 def remove_named_grouping_policies(ptype, rules) rules_removed = parent_remove_policies('g', ptype, rules) auto_build_role_links ? build_role_links : rules_removed end |
#remove_named_grouping_policy(ptype, *params) ⇒ Object
removes a role inheritance rule from the current named policy.
270 271 272 273 274 275 276 277 278 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 270 def remove_named_grouping_policy(ptype, *params) rule_added = if params.size == 1 && params[0].is_a?(Array) parent_remove_policy('g', ptype, params[0]) else parent_remove_policy('g', ptype, params) end auto_build_role_links ? build_role_links : rule_added end |
#remove_named_policies(ptype, rules) ⇒ Object
removes authorization rules from the current named policy.
190 191 192 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 190 def remove_named_policies(ptype, rules) parent_remove_policies('p', ptype, rules) end |
#remove_named_policy(ptype, *params) ⇒ Object
removes an authorization rule from the current named policy.
181 182 183 184 185 186 187 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 181 def remove_named_policy(ptype, *params) if params.size == 1 && params[0].is_a?(Array) parent_remove_policy('p', ptype, params[0]) else parent_remove_policy('p', ptype, params) end end |
#remove_policies(rules) ⇒ Object
removes authorization rules from the current policy.
171 172 173 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 171 def remove_policies(rules) remove_named_policies('p', rules) end |
#remove_policy(*params) ⇒ Object
removes an authorization rule from the current policy.
166 167 168 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 166 def remove_policy(*params) remove_named_policy('p', *params) end |
#update_named_policies(ptype, old_rules, new_rules) ⇒ Object
updates authorization rules from the current named policy.
161 162 163 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 161 def update_named_policies(ptype, old_rules, new_rules) parent_update_policies('p', ptype, old_rules, new_rules) end |
#update_named_policy(ptype, old_rule, new_rule) ⇒ Object
updates an authorization rule from the current named policy.
156 157 158 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 156 def update_named_policy(ptype, old_rule, new_rule) parent_update_policy('p', ptype, old_rule, new_rule) end |
#update_policies(old_rules, new_rules) ⇒ Object
updates authorization rules from the current policy.
151 152 153 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 151 def update_policies(old_rules, new_rules) update_named_policies('p', old_rules, new_rules) end |
#update_policy(old_rule, new_rule) ⇒ Object
updates an authorization rule from the current policy.
146 147 148 |
# File 'lib/casbin-ruby/management_enforcer.rb', line 146 def update_policy(old_rule, new_rule) update_named_policy('p', old_rule, new_rule) end |