Skip to content

Commit a941f1c

Browse files
author
Roland Hedberg
committed
Support for more arguments
1 parent 52205fe commit a941f1c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/saml2/client_base.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from saml2.mdstore import destinations
1515
from saml2.profile import paos, ecp
1616
from saml2.saml import NAMEID_FORMAT_TRANSIENT
17-
from saml2.samlp import AuthnQuery
17+
from saml2.samlp import AuthnQuery, RequestedAuthnContext
1818
from saml2.samlp import NameIDMappingRequest
1919
from saml2.samlp import AttributeQuery
2020
from saml2.samlp import AuthzDecisionQuery
@@ -252,6 +252,26 @@ def create_authn_request(self, destination, vorg="", scoping=None,
252252
else:
253253
args["provider_name"] = self._my_name()
254254

255+
# Allow argument values either as class instances or as dictionaries
256+
_msg = AuthnRequest()
257+
for param in ["scoping", "requested_authn_context", "conditions",
258+
"subject", "scoping"]:
259+
try:
260+
_item = kwargs[param]
261+
except KeyError:
262+
pass
263+
else:
264+
del kwargs[param]
265+
# either class instance or argument dictionary
266+
if isinstance(_item, _msg.child_class(param)):
267+
args[param] = _item
268+
elif isinstance(_item, dict):
269+
args[param] = RequestedAuthnContext(**_item)
270+
else:
271+
raise ValueError("%s or wrong type expected %s" % (_item,
272+
param))
273+
274+
255275
try:
256276
args["name_id_policy"] = kwargs["name_id_policy"]
257277
del kwargs["name_id_policy"]

0 commit comments

Comments
 (0)