diff options
author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2020-11-23 13:29:35 +0200 |
---|---|---|
committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2020-11-23 14:58:14 +0200 |
commit | e208dfdd76f5bc58bd462abf2109be5130016217 (patch) | |
tree | 529e3c10a27d0540027aa33aa3e73589efe493cf | |
parent | 7352484f8717dce88bea837239c5ea2d6018deb4 (diff) | |
download | pysaml2-e208dfdd76f5bc58bd462abf2109be5130016217.tar.gz |
Allow phase2 to specify signing algorithm; although unused atm
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
-rw-r--r-- | src/saml2/ecp_client.py | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/src/saml2/ecp_client.py b/src/saml2/ecp_client.py index 5265f99d..94cfe135 100644 --- a/src/saml2/ecp_client.py +++ b/src/saml2/ecp_client.py @@ -91,8 +91,16 @@ class Client(Entity): self.done_ecp = False self.cookie_jar = cookielib.LWPCookieJar() - def phase2(self, authn_request, rc_url, idp_entity_id, headers=None, - sign=False, **kwargs): + def phase2( + self, + authn_request, + rc_url, + idp_entity_id, + headers=None, + sign=False, + sign_alg=None, + **kwargs, + ): """ Doing the second phase of the ECP conversation, the conversation with the IdP happens. @@ -105,12 +113,13 @@ class Client(Entity): :return: The response from the IdP """ - _, destination = self.pick_binding("single_sign_on_service", - [BINDING_SOAP], "idpsso", - entity_id=idp_entity_id) + _, destination = self.pick_binding( + "single_sign_on_service", [BINDING_SOAP], "idpsso", entity_id=idp_entity_id + ) - ht_args = self.apply_binding(BINDING_SOAP, authn_request, destination, - sign=sign) + ht_args = self.apply_binding( + BINDING_SOAP, authn_request, destination, sign=sign, sigalg=sign_alg + ) if headers: ht_args["headers"].extend(headers) @@ -124,8 +133,10 @@ class Client(Entity): if response.status_code != 200: raise SAMLError( - "Request to IdP failed (%s): %s" % (response.status_code, - response.text)) + "Request to IdP failed ({status}): {text}".format( + status=response.status_code, text=response.text + ) + ) # SAMLP response in a SOAP envelope body, ecp response in headers respdict = self.parse_soap_message(response.text) @@ -195,8 +206,11 @@ class Client(Entity): _rc_url = _paos_request.response_consumer_url - return {"authn_request": authn_request, "rc_url": _rc_url, - "relay_state": _relay_state} + return { + "authn_request": authn_request, + "rc_url": _rc_url, + "relay_state": _relay_state, + } def ecp_conversation(self, respdict, idp_entity_id=None): """ @@ -218,8 +232,7 @@ class Client(Entity): # Phase 3 - back to the SP # ********************************** - ht_args = self.use_soap(idp_response, args["rc_url"], - [args["relay_state"]]) + ht_args = self.use_soap(idp_response, args["rc_url"], [args["relay_state"]]) ht_args["headers"][0] = ('Content-Type', MIME_PAOS) logger.debug("[P3] Post to SP: %s", ht_args["data"]) @@ -231,8 +244,7 @@ class Client(Entity): # url I started off with. pass else: - raise SAMLError( - "Error POSTing package to SP: %s" % response.text) + raise SAMLError("Error POSTing package to SP: %s" % response.text) logger.debug("[P3] SP response: %s", response.text) |