Skip to content

Commit a25103f

Browse files
committed
Fix #242: make sure status code is always returned in http_info dict
1 parent 344ca99 commit a25103f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/saml2/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def apply_binding(self, binding, msg_str, destination="", relay_state="",
241241
if response:
242242
info = self.use_http_artifact(msg_str, destination, relay_state)
243243
info["method"] = "GET"
244-
info["status"] = 302
244+
info["status"] = 302 # TODO: should be 303 on >= HTTP/1.1
245245
else:
246246
info = self.use_http_artifact(msg_str, destination, relay_state)
247247
else:

src/saml2/pack.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def http_form_post_message(message, location, relay_state="",
111111
relay_state_input=relay_state_input,
112112
action=location)
113113

114-
return {"headers": [("Content-type", "text/html")], "data": response}
114+
return {"headers": [("Content-type", "text/html")], "data": response, "status": 200}
115115

116116

117117
def http_post_message(message, relay_state="", typ="SAMLRequest", **kwargs):
@@ -137,7 +137,8 @@ def http_post_message(message, relay_state="", typ="SAMLRequest", **kwargs):
137137
part["RelayState"] = relay_state
138138

139139
return {"headers": [("Content-type", 'application/x-www-form-urlencoded')],
140-
"data": urlencode(part)}
140+
"data": urlencode(part),
141+
"status": 200}
141142

142143

143144
def http_redirect_message(message, location, relay_state="", typ="SAMLRequest",
@@ -197,7 +198,7 @@ def http_redirect_message(message, location, relay_state="", typ="SAMLRequest",
197198
headers = [('Location', str(login_url))]
198199
body = []
199200

200-
return {"headers": headers, "data": body}
201+
return {"headers": headers, "data": body, "status": 303}
201202

202203

203204
DUMMY_NAMESPACE = "http://example.org/"
@@ -257,12 +258,14 @@ def make_soap_enveloped_saml_thingy(thingy, header_parts=None):
257258

258259
def http_soap_message(message):
259260
return {"headers": [("Content-type", "application/soap+xml")],
260-
"data": make_soap_enveloped_saml_thingy(message)}
261+
"data": make_soap_enveloped_saml_thingy(message),
262+
"status": 200}
261263

262264

263265
def http_paos(message, extra=None):
264266
return {"headers": [("Content-type", "application/soap+xml")],
265-
"data": make_soap_enveloped_saml_thingy(message, extra)}
267+
"data": make_soap_enveloped_saml_thingy(message, extra),
268+
"status": 200}
266269

267270

268271
def parse_soap_enveloped_saml(text, body_class, header_class=None):

0 commit comments

Comments
 (0)