This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/passbook/channels/in_saml/xml_render.py

27 lines
745 B
Python

"""Functions for creating XML output."""
from structlog import get_logger
from passbook.channels.out_saml.utils.xml_signing import get_signature_xml
from passbook.lib.utils.template import render_to_string
LOGGER = get_logger()
def get_authnrequest_xml(parameters, signed=False):
"""Get AuthN Request XML"""
# Reset signature.
params = {}
params.update(parameters)
params["AUTHN_REQUEST_SIGNATURE"] = ""
unsigned = render_to_string("saml/sp/xml/authn_request.xml", params)
if not signed:
return unsigned
# Sign it.
signature_xml = get_signature_xml()
params["AUTHN_REQUEST_SIGNATURE"] = signature_xml
signed = render_to_string("saml/sp/xml/authn_request.xml", params)
return signed