Skip to content

Commit

Permalink
feat: add support for add_domain_matching_function (#165)
Browse files Browse the repository at this point in the history
* feat: add support for add_domain_matching_function

Signed-off-by: Zxilly <zhouxinyu1001@gmail.com>

* style: remove unused code

Signed-off-by: Zxilly <zhouxinyu1001@gmail.com>

* perf: fix enforcer API

Signed-off-by: Zxilly <zhouxinyu1001@gmail.com>

* test: fix readlock tests

Signed-off-by: Zxilly <zhouxinyu1001@gmail.com>

* fix: add error handler for potential keymatch error

Signed-off-by: Zxilly <zhouxinyu1001@gmail.com>

* style: reformat by black

Signed-off-by: Zxilly <zhouxinyu1001@gmail.com>
  • Loading branch information
Zxilly authored Jun 27, 2021
1 parent 85b0bcb commit 19b9503
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 118 deletions.
6 changes: 3 additions & 3 deletions casbin/core_enforcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ def add_named_matching_func(self, ptype, fn):

def add_named_domain_matching_func(self, ptype, fn):
"""add_named_domain_matching_func add MatchingFunc by ptype to RoleManager"""
try:
if ptype in self.rm_map.keys():
self.rm_map[ptype].add_domain_matching_func(fn)
return True
except:
return False

return False

def enforce(self, *rvals):
"""decides whether a "subject" can access a "object" with the operation "action",
Expand Down
2 changes: 1 addition & 1 deletion casbin/enforcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def get_implicit_roles_for_user(self, name, domain=None):

return res

def get_implicit_permissions_for_user(self, user, domain=None):
def get_implicit_permissions_for_user(self, user, domain=""):
"""
gets implicit permissions for a user or role.
Compared to get_permissions_for_user(), this function retrieves permissions for inherited roles.
Expand Down
Loading

0 comments on commit 19b9503

Please sign in to comment.