Skip to content

Commit ffa2836

Browse files
author
Roland Hedberg
committed
Merge pull request #178 from tpazderka/Authn_broker-for-exact
Authn_Broker fixed
2 parents cf7b831 + 9d96905 commit ffa2836

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/saml2/authn_context/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,20 @@ def pick(self, req_authn_context=None):
166166
if req_authn_context.comparison:
167167
_cmp = req_authn_context.comparison
168168
else:
169-
_cmp = "minimum"
170-
return self._pick_by_class_ref(
171-
req_authn_context.authn_context_class_ref[0].text, _cmp)
169+
_cmp = "exact"
170+
if _cmp == 'exact':
171+
res = []
172+
for cls_ref in req_authn_context.authn_context_class_ref:
173+
res += (self._pick_by_class_ref(cls_ref.text, _cmp))
174+
return res
175+
else:
176+
return self._pick_by_class_ref(
177+
req_authn_context.authn_context_class_ref[0].text, _cmp)
172178
elif req_authn_context.authn_context_decl_ref:
173179
if req_authn_context.comparison:
174180
_cmp = req_authn_context.comparison
175181
else:
176-
_cmp = "minimum"
182+
_cmp = "exact"
177183
return self._pick_by_class_ref(
178184
req_authn_context.authn_context_decl_ref, _cmp)
179185

tests/test_77_authn_context.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,24 @@ def test_authn_3():
142142
method, ref = info[0]
143143
assert REF2METHOD[AL1] == method
144144

145+
rac = requested_authn_context([AL1, AL2], "exact")
146+
147+
info = authn.pick(rac)
148+
assert len(info) == 2
149+
method, ref = info[0]
150+
assert REF2METHOD[AL1] == method
151+
method, ref = info[1]
152+
assert REF2METHOD[AL2] == method
153+
154+
rac = requested_authn_context([AL3, AL2], "exact")
155+
156+
info = authn.pick(rac)
157+
assert len(info) == 2
158+
method, ref = info[0]
159+
assert REF2METHOD[AL3] == method
160+
method, ref = info[1]
161+
assert REF2METHOD[AL2] == method
162+
145163
rac = requested_authn_context(AL1, "better")
146164

147165
info = authn.pick(rac)

0 commit comments

Comments
 (0)