diff options
author | Roland Hedberg <roland.hedberg@adm.umu.se> | 2015-11-13 15:41:31 +0100 |
---|---|---|
committer | Roland Hedberg <roland.hedberg@adm.umu.se> | 2015-11-13 15:41:31 +0100 |
commit | 17c748f516d6abe5f9f39e3c69e523b8f8177195 (patch) | |
tree | 2b1e5de9f2664807edb44e849f549031c554294c /src/saml2/pack.py | |
parent | 373668e1d32d00822330183cad9e4f7a12d0b3fc (diff) | |
download | pysaml2-17c748f516d6abe5f9f39e3c69e523b8f8177195.tar.gz |
The IdP doing form_post or the SP doing post is two different things.
Diffstat (limited to 'src/saml2/pack.py')
-rw-r--r-- | src/saml2/pack.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/saml2/pack.py b/src/saml2/pack.py index 3377c451..ed4142a0 100644 --- a/src/saml2/pack.py +++ b/src/saml2/pack.py @@ -79,6 +79,32 @@ def http_form_post_message(message, location, relay_state="", return {"headers": [("Content-type", "text/html")], "data": response} +def http_post_message(message, relay_state="", typ="SAMLRequest", **kwargs): + """ + + :param message: The message + :param relay_state: for preserving and conveying state information + :return: A tuple containing header information and a HTML message. + """ + if not isinstance(message, six.string_types): + message = str(message) + if not isinstance(message, six.binary_type): + message = message.encode('utf-8') + + if typ == "SAMLRequest" or typ == "SAMLResponse": + _msg = base64.b64encode(message) + else: + _msg = message + _msg = _msg.decode('ascii') + + part = {typ: _msg} + if relay_state: + part["RelayState"] = relay_state + + return {"headers": [("Content-type", 'application/x-www-form-urlencoded')], + "data": urlencode(part)} + + def http_redirect_message(message, location, relay_state="", typ="SAMLRequest", sigalg=None, key=None, **kwargs): """The HTTP Redirect binding defines a mechanism by which SAML protocol |