def http_redirect_message(message, location, relay_state="", typ="SAMLRequest",
                          sigalg='', signer=None, **kwargs):
    """The HTTP Redirect binding defines a mechanism by which SAML protocol
    messages can be transmitted within URL parameters.
    Messages are encoded for use with this binding using a URL encoding
    technique, and transmitted using the HTTP GET method.

    The DEFLATE Encoding is used in this function.

    :param message: The message
    :param location: Where the message should be posted to
    :param relay_state: for preserving and conveying state information
    :param typ: What type of message it is SAMLRequest/SAMLResponse/SAMLart
    :param sigalg: Which algorithm the signature function will use to sign
        the message
    :param signer: A signature function that can be used to sign the message
    :return: A tuple containing header information and a HTML message.
    """

    if not isinstance(message, six.string_types):
        message = "%s" % (message,)

    _order = None
    if typ in ["SAMLRequest", "SAMLResponse"]:
        if typ == "SAMLRequest":
            _order = REQ_ORDER
        else:
            _order = RESP_ORDER
        args = {typ: deflate_and_base64_encode(message)}
    elif typ == "SAMLart":
        args = {typ: message}
    else:
        raise Exception("Unknown message type: %s" % typ)

    if relay_state:
        args["RelayState"] = relay_state

    if signer:
        # sigalgs, should be one defined in xmldsig
        assert sigalg in [b for a, b in SIG_ALLOWED_ALG]
        args["SigAlg"] = sigalg

        string = "&".join([urlencode({k: args[k]})
                           for k in _order if k in args]).encode('ascii')
        args["Signature"] = base64.b64encode(signer.sign(string))
        string = urlencode(args)
    else:
        string = urlencode(args)

    glue_char = "&" if urlparse(location).query else "?"
    login_url = glue_char.join([location, string])
    headers = [('Location', str(login_url))]
    body = []

    return {"headers": headers, "data": body}
def http_redirect_message ( message , location , relay_state = "" , typ = "SAMLRequest" , sigalg = '' , signer = None , ** kwargs ) : if not isinstance ( message , six . string_types ) : message = "%s" % ( message , ) _order = None if typ in [ "SAMLRequest" , "SAMLResponse" ] : if typ == "SAMLRequest" : _order = REQ_ORDER else : _order = RESP_ORDER args = { typ : deflate_and_base64_encode ( message ) } elif typ == "SAMLart" : args = { typ : message } else : raise Exception ( "Unknown message type: %s" % typ ) if relay_state : args [ "RelayState" ] = relay_state if signer : assert sigalg in [ b for a , b in SIG_ALLOWED_ALG ] args [ "SigAlg" ] = sigalg string = "&" . join ( [ urlencode ( { k : args [ k ] } ) for k in _order if k in args ] ) . encode ( 'ascii' ) args [ "Signature" ] = base64 . b64encode ( signer . sign ( string ) ) string = urlencode ( args ) else : string = urlencode ( args ) glue_char = "&" if urlparse ( location ) . query else "?" login_url = glue_char . join ( [ location , string ] ) headers = [ ( 'Location' , str ( login_url ) ) ] body = [ ] return { "headers" : headers , "data" : body }
The HTTP Redirect binding defines a mechanism by which SAML protocol
    messages can be transmitted within URL parameters.
    Messages are encoded for use with this binding using a URL encoding
    technique, and transmitted using the HTTP GET method.

    The DEFLATE Encoding is used in this function.

    :param message: The message
    :param location: Where the message should be posted to
    :param relay_state: for preserving and conveying state information
    :param typ: What type of message it is SAMLRequest/SAMLResponse/SAMLart
    :param sigalg: Which algorithm the signature function will use to sign
        the message
    :param signer: A signature function that can be used to sign the message
    :return: A tuple containing header information and a HTML message.