Skip to content

Commit cf2bafc

Browse files
committed
refactor
1 parent 0fbf856 commit cf2bafc

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/satosa/micro_services/attribute_authorization.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
from .base import ResponseMicroService
44
from ..exception import SATOSAAuthenticationError
5-
6-
def _filters(f, requester, provider):
7-
pf = f.get(provider, f.get("", f.get("default", {})))
8-
rf = pf.get(requester, pf.get("", pf.get("default", {})))
9-
return rf.items()
5+
from ..util import get_dict_defaults
106

117
class AttributeAuthorization(ResponseMicroService):
128

@@ -53,12 +49,12 @@ def __init__(self, config, *args, **kwargs):
5349
self.attribute_deny = config.get("attribute_deny", {})
5450

5551
def _check_authz(self, context, attributes, requester, provider):
56-
for attribute_name, attribute_filters in _filters(self.attribute_allow, requester, provider):
52+
for attribute_name, attribute_filters in get_dict_defaults(self.attribute_allow, requester, provider).items():
5753
if attribute_name in attributes:
5854
if not any([any(filter(re.compile(af).search, attributes[attribute_name])) for af in attribute_filters]):
5955
raise SATOSAAuthenticationError(context.state, "Permission denied")
6056

61-
for attribute_name, attribute_filters in _filters(self.attribute_deny, requester, provider):
57+
for attribute_name, attribute_filters in get_dict_defaults(self.attribute_deny, requester, provider).items():
6258
if attribute_name in attributes:
6359
if any([any(filter(re.compile(af).search, attributes[attribute_name])) for af in attribute_filters]):
6460
raise SATOSAAuthenticationError(context.state, "Permission denied")

0 commit comments

Comments
 (0)