-
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 #3590 from open-formulieren/upgrade/automatically-…
…create-csp-form-action-config Set up automatic CSP form-action directive generation
- Loading branch information
Showing
8 changed files
with
206 additions
and
13 deletions.
There are no files selected for viewing
Empty file.
Empty file.
29 changes: 29 additions & 0 deletions
29
src/openforms/config/management/commands/create_csp_form_action_directives_from_config.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,29 @@ | ||
from django.core.management import BaseCommand | ||
|
||
from digid_eherkenning.models import DigidConfiguration, EherkenningConfiguration | ||
|
||
from openforms.payments.contrib.ogone.models import OgoneMerchant | ||
|
||
|
||
class Command(BaseCommand): | ||
help = ( | ||
"Introspect the runtime configuration and generate the relevant CSP " | ||
"form-action directives" | ||
) | ||
|
||
def handle(self, **options): | ||
ogone_merchants = OgoneMerchant.objects.exclude( | ||
endpoint_preset="", | ||
endpoint_custom="", | ||
) | ||
for ogone_merchant in ogone_merchants: | ||
ogone_merchant.save() # triggers CSPSetting record creation | ||
|
||
for model_cls in (DigidConfiguration, EherkenningConfiguration): | ||
configured_instance = model_cls.objects.exclude( | ||
idp_metadata_file="" | ||
).first() | ||
if configured_instance is None: | ||
continue | ||
|
||
configured_instance.save() # triggers CSPSetting record creation |
21 changes: 21 additions & 0 deletions
21
src/openforms/config/migrations/0060_create_csp_form_action_configs.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,21 @@ | ||
# Generated by Django 3.2.21 on 2023-11-09 08:58 | ||
|
||
from django.core.management import call_command | ||
from django.db import migrations | ||
|
||
|
||
def call_management_command(apps, schema_editor): | ||
call_command("create_csp_form_action_directives_from_config") | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("config", "0059_convert_button_design_tokens"), | ||
("payments_ogone", "0002_auto_20210902_2120"), | ||
("digid_eherkenning", "0006_digidconfiguration_metadata_file_source_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(call_management_command, migrations.RunPython.noop), | ||
] |
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