Fix KeyError when signing http_redirect_message

Without this change I get the following traceback:

>>> pack.http_redirect_message(req.to_string(), destination, sigalg=pack.RSA_SHA1, key=rsa)
Traceback (most recent call last):
  File "<redacted>", line 1, in <module>
  File "<redacted>\pysaml2-1.0.3-py2.7.egg\saml2\pack.py", line 138, in http_redirect_message
    string = "&".join([urllib.urlencode({k: args[k]}) for k in _order])
KeyError: 'RelayState'
This commit is contained in:
Paul Korzhyk
2013-11-04 16:09:09 +11:00
parent 2f4d460519
commit fc12632ff1

View File

@@ -135,7 +135,7 @@ def http_redirect_message(message, location, relay_state="", typ="SAMLRequest",
if sigalg == RSA_SHA1:
signer = RSASigner(sha1_digest, "sha1")
string = "&".join([urllib.urlencode({k: args[k]}) for k in _order])
string = "&".join([urllib.urlencode({k: args[k]}) for k in _order if k in args])
args["Signature"] = base64.b64encode(signer.sign(string, key))
string = urllib.urlencode(args)
else:
@@ -265,4 +265,4 @@ def packager(identifier):
def factory(binding, message, location, relay_state="", typ="SAMLRequest"):
return PACKING[binding](message, location, relay_state, typ)
return PACKING[binding](message, location, relay_state, typ)