Skip to content

Commit d7de930

Browse files
committed
Deny auth if requested attribute is missing
If a requested attribute is missing the authorization should fail
1 parent 802ec54 commit d7de930

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/satosa/micro_services/attribute_authorization.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ def _check_authz(self, context, attributes, requester, provider):
5353
if attribute_name in attributes:
5454
if not any([any(filter(re.compile(af).search, attributes[attribute_name])) for af in attribute_filters]):
5555
raise SATOSAAuthenticationError(context.state, "Permission denied")
56+
else:
57+
raise SATOSAAuthenticationError(context.state, "Permission denied")
58+
5659

5760
for attribute_name, attribute_filters in get_dict_defaults(self.attribute_deny, requester, provider).items():
5861
if attribute_name in attributes:

tests/satosa/micro_services/test_attribute_authorization.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ def test_authz_allow_fail(self):
4444
ctx.state = dict()
4545
authz_service.process(ctx, resp)
4646

47+
def test_authz_allow_missing(self):
48+
attribute_allow = {
49+
"": { "default": {"a0": ['foo1','foo2']} }
50+
}
51+
attribute_deny = {}
52+
authz_service = self.create_authz_service(attribute_allow, attribute_deny)
53+
resp = InternalData(auth_info=AuthenticationInformation())
54+
resp.attributes = {
55+
}
56+
with pytest.raises(SATOSAAuthenticationError):
57+
ctx = Context()
58+
ctx.state = dict()
59+
authz_service.process(ctx, resp)
60+
4761
def test_authz_allow_second(self):
4862
attribute_allow = {
4963
"": { "default": {"a0": ['foo1','foo2']} }

0 commit comments

Comments
 (0)