providers/saml: move templates into correct folder

This commit is contained in:
Jens Langhammer 2020-06-20 21:49:16 +02:00
parent 42e9ce4f72
commit a0f05caf8e
19 changed files with 13 additions and 14 deletions

View File

@ -59,7 +59,7 @@ class SAMLProviderForm(forms.ModelForm):
class SAMLPropertyMappingForm(forms.ModelForm): class SAMLPropertyMappingForm(forms.ModelForm):
"""SAML Property Mapping form""" """SAML Property Mapping form"""
template_name = "saml/idp/property_mapping_form.html" template_name = "providers/saml/property_mapping_form.html"
def clean_expression(self): def clean_expression(self):
"""Test Syntax""" """Test Syntax"""

View File

@ -132,7 +132,7 @@ class Processor:
continue continue
self._assertion_params["ATTRIBUTES"] = attributes self._assertion_params["ATTRIBUTES"] = attributes
self._assertion_xml = get_assertion_xml( self._assertion_xml = get_assertion_xml(
"saml/xml/assertions/generic.xml", self._assertion_params, signed=True "providers/saml/xml/assertions/generic.xml", self._assertion_params, signed=True
) )
def _format_response(self): def _format_response(self):

View File

@ -10,5 +10,5 @@ class SalesForceProcessor(GenericProcessor):
def _format_assertion(self): def _format_assertion(self):
super()._format_assertion() super()._format_assertion()
self._assertion_xml = get_assertion_xml( self._assertion_xml = get_assertion_xml(
"saml/xml/assertions/salesforce.xml", self._assertion_params, signed=True "providers/saml/xml/assertions/salesforce.xml", self._assertion_params, signed=True
) )

View File

@ -3,7 +3,7 @@
IssueInstant="{{ ISSUE_INSTANT }}" IssueInstant="{{ ISSUE_INSTANT }}"
Version="2.0"> Version="2.0">
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">{{ ISSUER }}</saml:Issuer> <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">{{ ISSUER }}</saml:Issuer>
{% include 'saml/xml/signature.xml' %} {% include 'providers/saml/xml/signature.xml' %}
{{ SUBJECT_STATEMENT }} {{ SUBJECT_STATEMENT }}
<saml:Conditions NotBefore="{{ NOT_BEFORE }}" NotOnOrAfter="{{ NOT_ON_OR_AFTER }}"> <saml:Conditions NotBefore="{{ NOT_BEFORE }}" NotOnOrAfter="{{ NOT_ON_OR_AFTER }}">
<saml:AudienceRestriction> <saml:AudienceRestriction>

View File

@ -3,8 +3,8 @@
IssueInstant="{{ ISSUE_INSTANT }}" IssueInstant="{{ ISSUE_INSTANT }}"
Version="2.0"> Version="2.0">
<saml:Issuer>{{ ISSUER }}</saml:Issuer> <saml:Issuer>{{ ISSUER }}</saml:Issuer>
{% include 'saml/xml/signature.xml' %} {% include 'providers/saml/xml/signature.xml' %}
{% include 'saml/xml/subject.xml' %} {% include 'providers/saml/xml/subject.xml' %}
<saml:Conditions NotBefore="{{ NOT_BEFORE }}" NotOnOrAfter="{{ NOT_ON_OR_AFTER }}" /> <saml:Conditions NotBefore="{{ NOT_BEFORE }}" NotOnOrAfter="{{ NOT_ON_OR_AFTER }}" />
<saml:AuthnStatement AuthnInstant="{{ AUTH_INSTANT }}"> <saml:AuthnStatement AuthnInstant="{{ AUTH_INSTANT }}">
<saml:AuthnContext> <saml:AuthnContext>

View File

@ -4,7 +4,7 @@
Version="2.0"> Version="2.0">
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">{{ ISSUER }}</saml:Issuer> <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">{{ ISSUER }}</saml:Issuer>
{{ ASSERTION_SIGNATURE|safe }} {{ ASSERTION_SIGNATURE|safe }}
{% include 'saml/xml/subject.xml' %} {% include 'providers/saml/xml/subject.xml' %}
<saml:Conditions NotBefore="{{ NOT_BEFORE }}" NotOnOrAfter="{{ NOT_ON_OR_AFTER }}"> <saml:Conditions NotBefore="{{ NOT_BEFORE }}" NotOnOrAfter="{{ NOT_ON_OR_AFTER }}">
<saml:AudienceRestriction> <saml:AudienceRestriction>
<saml:Audience>{{ AUDIENCE }}</saml:Audience> <saml:Audience>{{ AUDIENCE }}</saml:Audience>

View File

@ -28,7 +28,7 @@ def _get_attribute_statement(params):
return return
# Build complete AttributeStatement. # Build complete AttributeStatement.
params["ATTRIBUTE_STATEMENT"] = render_to_string( params["ATTRIBUTE_STATEMENT"] = render_to_string(
"saml/xml/attributes.xml", {"attributes": attributes} "providers/saml/xml/attributes.xml", {"attributes": attributes}
) )
@ -48,7 +48,7 @@ def _get_in_response_to(params):
def _get_subject(params): def _get_subject(params):
"""Insert Subject. Modifies the params dict.""" """Insert Subject. Modifies the params dict."""
params["SUBJECT_STATEMENT"] = render_to_string("saml/xml/subject.xml", params) params["SUBJECT_STATEMENT"] = render_to_string("providers/saml/xml/subject.xml", params)
def get_assertion_xml(template, parameters, signed=False): def get_assertion_xml(template, parameters, signed=False):
@ -80,7 +80,7 @@ def get_response_xml(parameters, saml_provider: SAMLProvider, assertion_id=""):
params["RESPONSE_SIGNATURE"] = "" params["RESPONSE_SIGNATURE"] = ""
_get_in_response_to(params) _get_in_response_to(params)
raw_response = render_to_string("saml/xml/response.xml", params) raw_response = render_to_string("providers/saml/xml/response.xml", params)
if not saml_provider.signing_kp: if not saml_provider.signing_kp:
return raw_response return raw_response

View File

@ -35,4 +35,4 @@ def sign_with_signxml(data: str, provider: "SAMLProvider", reference_uri=None) -
def get_signature_xml() -> str: def get_signature_xml() -> str:
"""Returns XML Signature for subject.""" """Returns XML Signature for subject."""
return render_to_string("saml/xml/signature.xml", {}) return render_to_string("providers/saml/xml/signature.xml", {})

View File

@ -205,7 +205,7 @@ class SAMLFlowFinalView(StageView):
if provider.sp_binding == SAMLBindings.POST: if provider.sp_binding == SAMLBindings.POST:
return render( return render(
self.request, self.request,
"saml/idp/autosubmit_form.html", "providers/saml/autosubmit_form.html",
{ {
"url": response.acs_url, "url": response.acs_url,
"application": application, "application": application,
@ -257,7 +257,7 @@ class DescriptorDownloadView(LoginRequiredMixin, SAMLAccessMixin, View):
ctx["cert_public_key"] = strip_pem_header( ctx["cert_public_key"] = strip_pem_header(
provider.signing_kp.certificate_data.replace("\r", "") provider.signing_kp.certificate_data.replace("\r", "")
).replace("\n", "") ).replace("\n", "")
return render_to_string("saml/xml/metadata.xml", ctx) return render_to_string("providers/saml/xml/metadata.xml", ctx)
def get(self, request: HttpRequest, application_slug: str) -> HttpResponse: def get(self, request: HttpRequest, application_slug: str) -> HttpResponse:
"""Replies with the XML Metadata IDSSODescriptor.""" """Replies with the XML Metadata IDSSODescriptor."""

View File

@ -333,7 +333,6 @@ LOGGING = {
TEST = False TEST = False
TEST_RUNNER = "xmlrunner.extra.djangotestrunner.XMLTestRunner" TEST_RUNNER = "xmlrunner.extra.djangotestrunner.XMLTestRunner"
TEST_OUTPUT_VERBOSE = 2
LOG_LEVEL = CONFIG.y("log_level").upper() LOG_LEVEL = CONFIG.y("log_level").upper()
TEST_OUTPUT_FILE_NAME = "unittest.xml" TEST_OUTPUT_FILE_NAME = "unittest.xml"