Skip to content

Commit 19b9503

Browse files
authored
feat: add support for add_domain_matching_function (#165)
* 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>
1 parent 85b0bcb commit 19b9503

File tree

11 files changed

+273
-118
lines changed

11 files changed

+273
-118
lines changed

casbin/core_enforcer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ def add_named_matching_func(self, ptype, fn):
237237

238238
def add_named_domain_matching_func(self, ptype, fn):
239239
"""add_named_domain_matching_func add MatchingFunc by ptype to RoleManager"""
240-
try:
240+
if ptype in self.rm_map.keys():
241241
self.rm_map[ptype].add_domain_matching_func(fn)
242242
return True
243-
except:
244-
return False
243+
244+
return False
245245

246246
def enforce(self, *rvals):
247247
"""decides whether a "subject" can access a "object" with the operation "action",

casbin/enforcer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def get_implicit_roles_for_user(self, name, domain=None):
136136

137137
return res
138138

139-
def get_implicit_permissions_for_user(self, user, domain=None):
139+
def get_implicit_permissions_for_user(self, user, domain=""):
140140
"""
141141
gets implicit permissions for a user or role.
142142
Compared to get_permissions_for_user(), this function retrieves permissions for inherited roles.

0 commit comments

Comments
 (0)