class Casbin::ManagementEnforcer

ManagementEnforcer = InternalEnforcer + Management API.

Public Instance Methods

add_function(name, func) click to toggle source

adds a customized function.

# File lib/casbin-ruby/management_enforcer.rb, line 293
def add_function(name, func)
  fm.add_function(name, func)
end
add_grouping_policies(rules) click to toggle source

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.

# 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) click to toggle source

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.

# 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) click to toggle source

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.

# 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) click to toggle source

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.

# 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) click to toggle source

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.

# 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) click to toggle source

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.

# 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) click to toggle source

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.

# File lib/casbin-ruby/management_enforcer.rb, line 121
def add_policies(rules)
  add_named_policies('p', rules)
end
Also aliased as: parent_add_policies
add_policy(*params) click to toggle source

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.

# File lib/casbin-ruby/management_enforcer.rb, line 113
def add_policy(*params)
  add_named_policy('p', *params)
end
Also aliased as: parent_add_policy
get_all_actions() click to toggle source

gets the list of actions that show up in the current policy.

# File lib/casbin-ruby/management_enforcer.rb, line 37
def get_all_actions
  get_all_named_actions('p')
end
get_all_named_actions(ptype) click to toggle source

gets the list of actions that show up in the current named policy.

# 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) click to toggle source

gets the list of objects that show up in the current named policy.

# 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) click to toggle source
# 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) click to toggle source

gets the list of subjects that show up in the current named policy.

# 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() click to toggle source

gets the list of objects that show up in the current policy.

# File lib/casbin-ruby/management_enforcer.rb, line 27
def get_all_objects
  get_all_named_objects('p')
end
get_all_roles() click to toggle source

gets the list of roles that show up in the current named policy.

# File lib/casbin-ruby/management_enforcer.rb, line 47
def get_all_roles
  get_all_named_roles('g')
end
get_all_subjects() click to toggle source

gets the list of subjects that show up in the current policy.

# 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) click to toggle source

gets all the role inheritance rules in the policy, field filters can be specified.

# 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) click to toggle source

gets all the role inheritance rules in the policy, field filters can be specified.

# 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) click to toggle source

gets all the authorization rules in the named policy, field filters can be specified.

# 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) click to toggle source

gets all the authorization rules in the policy, field filters can be specified.

# 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() click to toggle source

gets all the role inheritance rules in the policy.

# File lib/casbin-ruby/management_enforcer.rb, line 76
def get_grouping_policy
  get_named_grouping_policy('g')
end
get_named_grouping_policy(ptype) click to toggle source

gets all the role inheritance rules in the policy.

# 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) click to toggle source

gets all the authorization rules in the named policy.

# File lib/casbin-ruby/management_enforcer.rb, line 66
def get_named_policy(ptype)
  model.get_policy('p', ptype)
end
get_policy() click to toggle source

gets all the authorization rules in the policy.

# File lib/casbin-ruby/management_enforcer.rb, line 56
def get_policy
  get_named_policy('p')
end
has_grouping_policy() click to toggle source

determines whether a role inheritance rule exists.

# 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) click to toggle source

determines whether a named role inheritance rule exists.

# 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) click to toggle source

determines whether a named authorization rule exists.

# 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) click to toggle source

determines whether an authorization rule exists.

# File lib/casbin-ruby/management_enforcer.rb, line 96
def has_policy(*params)
  has_named_policy('p', *params)
end
parent_add_policies(rules)
Alias for: add_policies
parent_add_policy(*params)
Alias for: add_policy
parent_remove_filtered_policy(field_index, *field_values)
parent_remove_policies(rules)
Alias for: remove_policies
parent_remove_policy(*params)
Alias for: remove_policy
parent_update_policies(old_rules, new_rules)
Alias for: update_policies
parent_update_policy(old_rule, new_rule)
Alias for: update_policy
remove_filtered_grouping_policy(field_index, *field_values) click to toggle source

removes a role inheritance rule from the current policy, field filters can be specified.

# 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) click to toggle source

removes a role inheritance rule from the current named policy, field filters can be specified.

# 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) click to toggle source

removes an authorization rule from the current named policy, field filters can be specified.

# 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) click to toggle source

removes an authorization rule from the current policy, field filters can be specified.

# 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) click to toggle source

removes role inheritance rulea from the current policy.

# 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) click to toggle source

removes a role inheritance rule from the current policy.

# 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) click to toggle source

removes role inheritance rules from the current named policy.

# 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) click to toggle source

removes a role inheritance rule from the current named policy.

# 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) click to toggle source

removes authorization rules from the current named policy.

# 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) click to toggle source

removes an authorization rule from the current named policy.

# 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) click to toggle source

removes authorization rules from the current policy.

# File lib/casbin-ruby/management_enforcer.rb, line 171
def remove_policies(rules)
  remove_named_policies('p', rules)
end
Also aliased as: parent_remove_policies
remove_policy(*params) click to toggle source

removes an authorization rule from the current policy.

# File lib/casbin-ruby/management_enforcer.rb, line 166
def remove_policy(*params)
  remove_named_policy('p', *params)
end
Also aliased as: parent_remove_policy
update_named_policies(ptype, old_rules, new_rules) click to toggle source

updates authorization rules from the current named policy.

# 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) click to toggle source

updates an authorization rule from the current named policy.

# 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) click to toggle source

updates authorization rules from the current policy.

# 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
Also aliased as: parent_update_policies
update_policy(old_rule, new_rule) click to toggle source

updates an authorization rule from the current policy.

# 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
Also aliased as: parent_update_policy