-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3514 from open-formulieren/task/3477-set-dynamic-…
…form-action-csp-directive [#3477] Add dynamic form-action csp directive
- Loading branch information
Showing
21 changed files
with
690 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/openforms/config/migrations/0058_auto_20231026_1525.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 3.2.21 on 2023-10-26 13:25 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("contenttypes", "0002_remove_content_type_name"), | ||
("config", "0057_globalconfiguration_recipients_email_digest"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="cspsetting", | ||
name="content_type", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
to="contenttypes.contenttype", | ||
verbose_name="content type", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="cspsetting", | ||
name="object_id", | ||
field=models.TextField(blank=True, db_index=True, verbose_name="object id"), | ||
), | ||
migrations.AlterField( | ||
model_name="cspsetting", | ||
name="value", | ||
field=models.CharField( | ||
help_text="CSP header value", max_length=255, verbose_name="value" | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.contrib.admin.sites import AdminSite | ||
from django.test import TestCase | ||
from django.urls import reverse | ||
|
||
from openforms.config.models import CSPSetting | ||
from openforms.payments.contrib.ogone.tests.factories import OgoneMerchantFactory | ||
|
||
from ..admin import CSPSettingAdmin | ||
|
||
|
||
class TestCSPAdmin(TestCase): | ||
def test_content_type_link(self): | ||
OgoneMerchantFactory() | ||
|
||
csp = CSPSetting.objects.get() | ||
|
||
admin_site = AdminSite() | ||
admin = CSPSettingAdmin(CSPSetting, admin_site) | ||
|
||
expected_url = reverse( | ||
"admin:payments_ogone_ogonemerchant_change", | ||
kwargs={"object_id": str(csp.object_id)}, | ||
) | ||
expected_link = f'<a href="{expected_url}">{str(csp.content_object)}</a>' | ||
|
||
link = admin.content_type_link(csp) | ||
|
||
self.assertEqual(link, expected_link) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.apps import AppConfig | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
class DigidEherkenningApp(AppConfig): | ||
name = "openforms.contrib.digid_eherkenning" | ||
label = "contrib_digid_eherkenning" | ||
verbose_name = _("DigiD/Eherkenning utilities") | ||
|
||
def ready(self): | ||
# register the signals | ||
from .signals import trigger_csp_update # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from digid_eherkenning.models import DigidConfiguration, EherkenningConfiguration | ||
|
||
ADDITIONAL_CSP_VALUES = { | ||
DigidConfiguration: "https://digid.nl https://*.digid.nl", | ||
EherkenningConfiguration: "", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.db.models.signals import post_save | ||
from django.dispatch import receiver | ||
|
||
from digid_eherkenning.models import DigidConfiguration, EherkenningConfiguration | ||
|
||
from .utils import create_digid_eherkenning_csp_settings | ||
|
||
|
||
@receiver(post_save, sender=DigidConfiguration) | ||
@receiver(post_save, sender=EherkenningConfiguration) | ||
def trigger_csp_update( | ||
sender, instance: DigidConfiguration | EherkenningConfiguration, **kwargs | ||
): | ||
create_digid_eherkenning_csp_settings(instance) |
Empty file.
97 changes: 97 additions & 0 deletions
97
src/openforms/contrib/digid_eherkenning/tests/data/eherkenning-metadata.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:ns0="urn:etoegang:1.13:metadata-extension" ID="ONELOGIN_123456" entityID="urn:etoegang:DV:00000001111111111000:entities:9000" ns0:version="1.13"><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> | ||
<ds:SignedInfo> | ||
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> | ||
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/> | ||
<ds:Reference URI="#_60dad314-6aaf-4567-9434-2f66e5e79aa1"> | ||
<ds:Transforms> | ||
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/> | ||
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> | ||
</ds:Transforms> | ||
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/> | ||
<ds:DigestValue>mTSuC+50WptA9sO0wg/eFIyQtWofMlkbEYm5Zoj/GHo=</ds:DigestValue> | ||
</ds:Reference> | ||
</ds:SignedInfo> | ||
<ds:SignatureValue> </ds:SignatureValue> | ||
<ds:KeyInfo> | ||
<ds:X509Data> | ||
<ds:X509Certificate> </ds:X509Certificate> | ||
</ds:X509Data> | ||
</ds:KeyInfo> | ||
</ds:Signature> | ||
<md:Extensions> | ||
<mdrpi:PublicationInfo xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi" creationInstant="2020-09-23T13:48:27Z" publisher="https://eh01.connectis.nl/metadata/iwelcome/prod/urn_etoegang_HM_00000003520354760000_entities_1135_1.13.xml"/> | ||
<attr:EntityAttributes xmlns:attr="urn:oasis:names:tc:SAML:metadata:attribute"> | ||
<saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Name="urn:oasis:names:tc:SAML:attribute:assurance-certification" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"> | ||
<saml:AttributeValue>urn:etoegang:core:assurance-class:loa4</saml:AttributeValue> | ||
</saml:Attribute> | ||
</attr:EntityAttributes> | ||
</md:Extensions> | ||
<md:IDPSSODescriptor WantAuthnRequestsSigned="true" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"> | ||
<md:KeyDescriptor use="signing"> | ||
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> | ||
<ds:KeyName>Test key 0</ds:KeyName> | ||
<ds:X509Data> | ||
<ds:X509Certificate> </ds:X509Certificate> | ||
</ds:X509Data> | ||
</ds:KeyInfo> | ||
</md:KeyDescriptor> | ||
<md:KeyDescriptor use="signing"> | ||
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> | ||
<ds:KeyName>Test key 1</ds:KeyName> | ||
<ds:X509Data> | ||
<ds:X509Certificate> </ds:X509Certificate> | ||
</ds:X509Data> | ||
</ds:KeyInfo> | ||
</md:KeyDescriptor> | ||
<md:ArtifactResolutionService Binding="urn:oasis:names:tc:SAML:2.0:bindings:SOAP" Location="https://test-iwelcome.nl/broker/ars/1.13" index="0"/> | ||
<md:ArtifactResolutionService Binding="urn:oasis:names:tc:SAML:2.0:bindings:SOAP" Location="https://test-iwelcome.nl/broker/ars/1.13" index="1"/> | ||
<md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" Location="https://ehm01.iwelcome.nl/broker/slo/1.13"/> | ||
<md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://ehm01.iwelcome.nl/broker/slo/1.13"/> | ||
<md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://ehm01.iwelcome.nl/broker/slo/1.13"/> | ||
<md:NameIDFormat>urn:etoegang:1.9:EntityConcernedID:KvKnr</md:NameIDFormat> | ||
<md:NameIDFormat>urn:etoegang:1.9:IntermediateEntityID:KvKnr</md:NameIDFormat> | ||
<md:NameIDFormat>urn:etoegang:1.9:EntityConcernedID:Pseudo</md:NameIDFormat> | ||
<md:NameIDFormat>urn:etoegang:1.9:EntityConcernedID:RSIN</md:NameIDFormat> | ||
<md:NameIDFormat>urn:etoegang:1.9:IntermediateEntityID:RSIN</md:NameIDFormat> | ||
<md:NameIDFormat>urn:etoegang:1.11:EntityConcernedID:eIDASLegalIdentifier</md:NameIDFormat> | ||
<md:NameIDFormat>urn:etoegang:1.12:EntityConcernedID:BSN</md:NameIDFormat> | ||
<md:NameIDFormat>urn:etoegang:1.12:EntityConcernedID:PseudoID</md:NameIDFormat> | ||
<md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" Location="https://test-iwelcome.nl/broker/sso/1.13"/> | ||
<md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://test-iwelcome.nl/broker/sso/1.13"/> | ||
<md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://test-iwelcome.nl/broker/sso/1.13"/> | ||
</md:IDPSSODescriptor> | ||
<md:SPSSODescriptor AuthnRequestsSigned="true" WantAssertionsSigned="true" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"> | ||
<md:KeyDescriptor use="signing"> | ||
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> | ||
<ds:KeyName>Test key 2</ds:KeyName> | ||
<ds:X509Data> | ||
<ds:X509Certificate> </ds:X509Certificate> | ||
</ds:X509Data> | ||
</ds:KeyInfo> | ||
</md:KeyDescriptor> | ||
<md:KeyDescriptor use="signing"> | ||
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> | ||
<ds:KeyName>Test key 3</ds:KeyName> | ||
<ds:X509Data> | ||
<ds:X509Certificate> </ds:X509Certificate> | ||
</ds:X509Data> | ||
</ds:KeyInfo> | ||
</md:KeyDescriptor> | ||
<md:ArtifactResolutionService Binding="urn:oasis:names:tc:SAML:2.0:bindings:SOAP" Location="https://test-iwelcome.nl/broker/ars/1.13" index="0"/> | ||
<md:ArtifactResolutionService Binding="urn:oasis:names:tc:SAML:2.0:bindings:SOAP" Location="https://test-iwelcome.nl/broker/ars/1.13" index="1"/> | ||
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" Location="https://test-iwelcome.nl/broker/acs/1.13" index="1" isDefault="true"/> | ||
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" Location="https://test-iwelcome.nl/broker/acs/1.13" index="2" isDefault="false"/> | ||
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://test-iwelcome.nl/broker/acs/1.13" index="3" isDefault="false"/> | ||
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://test-iwelcome.nl/broker/acs/1.13" index="4" isDefault="false"/> | ||
<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact" Location="https://test-iwelcome.nl/broker/acs/1.13" index="5" isDefault="false"/> | ||
</md:SPSSODescriptor> | ||
<md:Organization> | ||
<md:OrganizationName xml:lang="en">Test-iWelcome</md:OrganizationName> | ||
<md:OrganizationDisplayName xml:lang="en">Test-iWelcome</md:OrganizationDisplayName> | ||
<md:OrganizationURL xml:lang="en">www.test-iwelcome.nl</md:OrganizationURL> | ||
</md:Organization> | ||
<md:ContactPerson contactType="administrative"> | ||
<md:EmailAddress>support@test-iwelcome.nl</md:EmailAddress> | ||
<md:TelephoneNumber>000 222 111</md:TelephoneNumber> | ||
</md:ContactPerson> | ||
</md:EntityDescriptor> |
Oops, something went wrong.