@@ -91,8 +91,16 @@ def __init__(self, user, passwd, sp="", idp=None, metadata_file=None,
91
91
self .done_ecp = False
92
92
self .cookie_jar = cookielib .LWPCookieJar ()
93
93
94
- def phase2 (self , authn_request , rc_url , idp_entity_id , headers = None ,
95
- sign = False , ** kwargs ):
94
+ def phase2 (
95
+ self ,
96
+ authn_request ,
97
+ rc_url ,
98
+ idp_entity_id ,
99
+ headers = None ,
100
+ sign = False ,
101
+ sign_alg = None ,
102
+ ** kwargs ,
103
+ ):
96
104
"""
97
105
Doing the second phase of the ECP conversation, the conversation
98
106
with the IdP happens.
@@ -105,12 +113,13 @@ def phase2(self, authn_request, rc_url, idp_entity_id, headers=None,
105
113
:return: The response from the IdP
106
114
"""
107
115
108
- _ , destination = self .pick_binding ("single_sign_on_service" ,
109
- [BINDING_SOAP ], "idpsso" ,
110
- entity_id = idp_entity_id )
116
+ _ , destination = self .pick_binding (
117
+ "single_sign_on_service" , [BINDING_SOAP ], "idpsso" , entity_id = idp_entity_id
118
+ )
111
119
112
- ht_args = self .apply_binding (BINDING_SOAP , authn_request , destination ,
113
- sign = sign )
120
+ ht_args = self .apply_binding (
121
+ BINDING_SOAP , authn_request , destination , sign = sign , sigalg = sign_alg
122
+ )
114
123
115
124
if headers :
116
125
ht_args ["headers" ].extend (headers )
@@ -124,8 +133,10 @@ def phase2(self, authn_request, rc_url, idp_entity_id, headers=None,
124
133
125
134
if response .status_code != 200 :
126
135
raise SAMLError (
127
- "Request to IdP failed (%s): %s" % (response .status_code ,
128
- response .text ))
136
+ "Request to IdP failed ({status}): {text}" .format (
137
+ status = response .status_code , text = response .text
138
+ )
139
+ )
129
140
130
141
# SAMLP response in a SOAP envelope body, ecp response in headers
131
142
respdict = self .parse_soap_message (response .text )
@@ -195,8 +206,11 @@ def parse_sp_ecp_response(respdict):
195
206
196
207
_rc_url = _paos_request .response_consumer_url
197
208
198
- return {"authn_request" : authn_request , "rc_url" : _rc_url ,
199
- "relay_state" : _relay_state }
209
+ return {
210
+ "authn_request" : authn_request ,
211
+ "rc_url" : _rc_url ,
212
+ "relay_state" : _relay_state ,
213
+ }
200
214
201
215
def ecp_conversation (self , respdict , idp_entity_id = None ):
202
216
"""
@@ -218,8 +232,7 @@ def ecp_conversation(self, respdict, idp_entity_id=None):
218
232
# Phase 3 - back to the SP
219
233
# **********************************
220
234
221
- ht_args = self .use_soap (idp_response , args ["rc_url" ],
222
- [args ["relay_state" ]])
235
+ ht_args = self .use_soap (idp_response , args ["rc_url" ], [args ["relay_state" ]])
223
236
ht_args ["headers" ][0 ] = ('Content-Type' , MIME_PAOS )
224
237
logger .debug ("[P3] Post to SP: %s" , ht_args ["data" ])
225
238
@@ -231,8 +244,7 @@ def ecp_conversation(self, respdict, idp_entity_id=None):
231
244
# url I started off with.
232
245
pass
233
246
else :
234
- raise SAMLError (
235
- "Error POSTing package to SP: %s" % response .text )
247
+ raise SAMLError ("Error POSTing package to SP: %s" % response .text )
236
248
237
249
logger .debug ("[P3] SP response: %s" , response .text )
238
250
0 commit comments