From 4f840dc1b72c61df3977d664a72a5a101cd9b9cf Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Thu, 27 Oct 2022 13:44:43 +0200 Subject: [PATCH] authenticators: add idp configuration info for saml and oidc (#67987) --- .../authenticator_add_form.html | 12 +++++ .../authenticators/authenticator_detail.html | 10 ++++ .../authenticators/templatetags/__init__.py | 0 .../templatetags/authenticator_extras.py | 10 ++++ src/authentic2_auth_oidc/models.py | 1 + .../idp_configuration_info.html | 8 ++++ src/authentic2_auth_saml/models.py | 1 + .../idp_configuration_info.html | 25 ++++++++++ tests/test_manager_authenticators.py | 47 ++++++++++++++++++- 9 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 src/authentic2/apps/authenticators/templatetags/__init__.py create mode 100644 src/authentic2/apps/authenticators/templatetags/authenticator_extras.py create mode 100644 src/authentic2_auth_oidc/templates/authentic2_auth_oidc/idp_configuration_info.html create mode 100644 src/authentic2_auth_saml/templates/authentic2_auth_saml/idp_configuration_info.html diff --git a/src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_add_form.html b/src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_add_form.html index f6aa9043a..7cbf26821 100644 --- a/src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_add_form.html +++ b/src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_add_form.html @@ -10,6 +10,15 @@
{% csrf_token %} {{ form|with_template }} + + {% for authenticator in form.authenticators.values %} + {% if authenticator.manager_idp_info_template_name %} +
+ {% include authenticator.manager_idp_info_template_name %} +
+ {% endif %} + {% endfor %} +
{% trans 'Cancel' %} @@ -19,8 +28,11 @@ $('div#authenticator span.required').remove(); name_field = $('div#id_name_p'); $('select#id_authenticator').change(function() { + $('div.idp-info').hide(); + $('div.idp-info.' + this.value).show(); if(this.value == 'saml' || this.value == 'oidc') { name_field.show(); + $('div#' + this.value + '-idp-info').show(); $('input#id_name').prop('required', true); } else { name_field.hide(); diff --git a/src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_detail.html b/src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_detail.html index a368a10bc..d65b930ec 100644 --- a/src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_detail.html +++ b/src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_detail.html @@ -36,6 +36,9 @@
+ {% if object.manager_idp_info_template_name %} + + {% endif %} {% for model in object.related_models %} {% endfor %} @@ -51,6 +54,13 @@ {% endfor %}
+ + {% if object.manager_idp_info_template_name %} +
+ {% include object.manager_idp_info_template_name %} +
+ {% endif %} + {% for model, objects in object.related_models.items %}