Skip to content

Commit 9a9c010

Browse files
author
Roland Hedberg
committed
Merge branch 'master' of github.com:rohe/pysaml2
2 parents e25bc70 + ffa2836 commit 9a9c010

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

src/saml2/authn_context/__init__.py

Lines changed: 13 additions & 5 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

@@ -215,6 +221,8 @@ def authn_context_class_ref(ref):
215221

216222

217223
def requested_authn_context(class_ref, comparison="minimum"):
224+
if not isinstance(class_ref, list):
225+
class_ref = [class_ref]
218226
return RequestedAuthnContext(
219-
authn_context_class_ref=[AuthnContextClassRef(text=class_ref)],
227+
authn_context_class_ref=[AuthnContextClassRef(text=i) for i in class_ref],
220228
comparison=comparison)

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)