-
Notifications
You must be signed in to change notification settings - Fork 0
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 #46 from maykinmedia/issue/45-retrieve-urls-from-m…
…etadata-file [#45] Retrieve digid/eherkenning metadata automatically
- Loading branch information
Showing
13 changed files
with
689 additions
and
40 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
30 changes: 30 additions & 0 deletions
30
digid_eherkenning/management/commands/update_stored_metadata.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,30 @@ | ||
from django.core.management import BaseCommand | ||
|
||
from digid_eherkenning.models.digid import DigidConfiguration | ||
from digid_eherkenning.models.eherkenning import EherkenningConfiguration | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Updates the stored metadata file and prepopulates the db fields." | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
"config_model", | ||
type=str, | ||
choices=["digid", "eherkenning"], | ||
help="Update the DigiD or Eherkenning configuration metadata.", | ||
) | ||
|
||
def handle(self, **options): | ||
if options["config_model"] == "digid": | ||
config = DigidConfiguration.get_solo() | ||
elif options["config_model"] == "eherkenning": | ||
config = EherkenningConfiguration.get_solo() | ||
|
||
if config.metadata_file_source: | ||
config.save() | ||
self.stdout.write(self.style.SUCCESS("Update was successful")) | ||
else: | ||
self.stdout.write( | ||
self.style.WARNING("Update failed, no metadata file source found") | ||
) |
79 changes: 79 additions & 0 deletions
79
digid_eherkenning/migrations/0006_digidconfiguration_metadata_file_source_and_more.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,79 @@ | ||
# Generated by Django 4.2.6 on 2023-10-20 08:40 | ||
|
||
from django.db import migrations, models | ||
import privates.fields | ||
import privates.storages | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
( | ||
"digid_eherkenning", | ||
"0005_alter_eherkenningconfiguration_eh_service_instance_uuid_and_more", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="digidconfiguration", | ||
name="metadata_file_source", | ||
field=models.URLField( | ||
default="", | ||
help_text="The URL-source where the XML metadata file can be retrieved from.", | ||
max_length=255, | ||
verbose_name="metadata file(XML) URL", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="eherkenningconfiguration", | ||
name="metadata_file_source", | ||
field=models.URLField( | ||
default="", | ||
help_text="The URL-source where the XML metadata file can be retrieved from.", | ||
max_length=255, | ||
verbose_name="metadata file(XML) URL", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="digidconfiguration", | ||
name="idp_metadata_file", | ||
field=privates.fields.PrivateMediaFileField( | ||
blank=True, | ||
help_text="The metadata file of the identity provider. This is auto populated from the configured source URL.", | ||
storage=privates.storages.PrivateMediaFileSystemStorage(), | ||
upload_to="", | ||
verbose_name="identity provider metadata", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="digidconfiguration", | ||
name="idp_service_entity_id", | ||
field=models.CharField( | ||
blank=True, | ||
help_text="Example value: 'https://was-preprod1.digid.nl/saml/idp/metadata'. Note that this must match the 'entityID' attribute on the 'md:EntityDescriptor' node found in the Identity Provider's metadata. This is auto populated from the configured source URL.", | ||
max_length=255, | ||
verbose_name="identity provider service entity ID", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="eherkenningconfiguration", | ||
name="idp_metadata_file", | ||
field=privates.fields.PrivateMediaFileField( | ||
blank=True, | ||
help_text="The metadata file of the identity provider. This is auto populated from the configured source URL.", | ||
storage=privates.storages.PrivateMediaFileSystemStorage(), | ||
upload_to="", | ||
verbose_name="identity provider metadata", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="eherkenningconfiguration", | ||
name="idp_service_entity_id", | ||
field=models.CharField( | ||
blank=True, | ||
help_text="Example value: 'https://was-preprod1.digid.nl/saml/idp/metadata'. Note that this must match the 'entityID' attribute on the 'md:EntityDescriptor' node found in the Identity Provider's metadata. This is auto populated from the configured source URL.", | ||
max_length=255, | ||
verbose_name="identity provider service entity ID", | ||
), | ||
), | ||
] |
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
14 changes: 14 additions & 0 deletions
14
digid_eherkenning/templates/admin/digid_eherkenning/widgets/custom_file_input.html
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 @@ | ||
<!-- Update the django-privates template in order to remove the clear and upload buttons since this field | ||
is automatically updated. User should only be able to download the file. --> | ||
|
||
{% if widget.is_initial %} | ||
{% if download_allowed %} | ||
<p class="file-upload">{{ widget.initial_text }}: <a href="{{ url }}">{{ display_value }}</a> | ||
{% else %} | ||
<p class="file-upload">{{ widget.initial_text }}: {{ display_value }} | ||
{% endif %} | ||
{% if not widget.required %} | ||
<span class="clearable-file-input"> | ||
{% endif %} | ||
<br /> | ||
{% endif %} |
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
Oops, something went wrong.