Projet

Général

Profil

0001-wip.patch

Valentin Deniaud, 27 octobre 2022 13:59

Télécharger (6,97 ko)

Voir les différences:

Subject: [PATCH] wip

 .../authenticators/authenticator_add_form.html | 10 ++++++++++
 .../authenticators/authenticator_detail.html   |  3 +++
 .../authenticators/templatetags/__init__.py    |  0
 .../templatetags/authenticator_extras.py       | 10 ++++++++++
 src/authentic2_auth_oidc/models.py             |  1 +
 .../idp_configuration_info.html                | 10 ++++++++++
 src/authentic2_auth_saml/models.py             |  1 +
 .../idp_configuration_info.html                | 18 ++++++++++++++++++
 8 files changed, 53 insertions(+)
 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
src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_add_form.html
10 10
  <form method="post" enctype="multipart/form-data">
11 11
    {% csrf_token %}
12 12
    {{ form|with_template }}
13

  
14
    {% for authenticator in form.authenticators.values %}
15
      {% if authenticator.manager_idp_info_template_name %}
16
        {% include authenticator.manager_idp_info_template_name %}
17
      {% endif %}
18
    {% endfor %}
19

  
13 20
    <div class="buttons">
14 21
      <button>{% trans "Add" %}</button>
15 22
      <a class="cancel" href="{% url 'a2-manager-authenticators' %}">{% trans 'Cancel' %}</a>
......
19 26
        $('div#authenticator span.required').remove();
20 27
        name_field = $('div#id_name_p');
21 28
        $('select#id_authenticator').change(function() {
29
          $('div.idp-info').hide();
30
          $('div.idp-info.' + this.value).show();
22 31
          if(this.value == 'saml' || this.value == 'oidc') {
23 32
            name_field.show();
33
            $('div#' + this.value + '-idp-info').show();
24 34
            $('input#id_name').prop('required', true);
25 35
          } else {
26 36
            name_field.hide();
src/authentic2/apps/authenticators/templates/authentic2/authenticators/authenticator_detail.html
45 45

  
46 46
      <div class="pk-tabs--container">
47 47
        <div aria-labelledby="tab-description" id="panel-description" role="tabpanel" tabindex="0">
48
          {% if object.manager_idp_info_template_name %}
49
            {% include object.manager_idp_info_template_name %}
50
          {% endif %}
48 51
          <ul>
49 52
            {% for line in object.get_full_description %}
50 53
              <li>{{ line }}</li>
src/authentic2/apps/authenticators/templatetags/authenticator_extras.py
1
from django import template
2

  
3
from authentic2.utils.misc import make_url
4

  
5
register = template.Library()
6

  
7

  
8
@register.simple_tag(takes_context=True)
9
def absolute_url(context, view_name, *args, **kwargs):
10
    return make_url(view_name, request=context['request'], absolute=True)
src/authentic2_auth_oidc/models.py
124 124

  
125 125
    type = 'oidc'
126 126
    how = ['oidc']
127
    manager_idp_info_template_name = 'authentic2_auth_oidc/idp_configuration_info.html'
127 128
    description_fields = ['show_condition', 'issuer', 'scopes', 'strategy', 'created', 'modified']
128 129

  
129 130
    class Meta:
src/authentic2_auth_oidc/templates/authentic2_auth_oidc/idp_configuration_info.html
1
{% load i18n authenticator_extras %}
2

  
3
<div class="infonotice oidc idp-info">
4
  <strong>{% trans "Configuration information for your identity provider" %}</strong>
5
  <ul>
6
    {% filter urlize %}
7
      <li>{% trans "Redirect URI (redirect_uri):" %} {% absolute_url 'oidc-login-callback' %}</li>
8
      <li>{% trans "Redirect URI after logout (post_logout_redirect_uri):" %} {% absolute_url 'auth_logout' %}</li>
9
    {% endfilter %}
10
  </div>
src/authentic2_auth_saml/models.py
162 162
    type = 'saml'
163 163
    how = ['saml']
164 164
    manager_view_template_name = 'authentic2_auth_saml/authenticator_detail.html'
165
    manager_idp_info_template_name = 'authentic2_auth_saml/idp_configuration_info.html'
165 166
    description_fields = ['show_condition', 'metadata_url', 'metadata_path', 'metadata', 'provision']
166 167

  
167 168
    class Meta:
src/authentic2_auth_saml/templates/authentic2_auth_saml/idp_configuration_info.html
1
{% load i18n authenticator_extras %}
2

  
3
<div class="infonotice saml idp-info">
4
  <strong>{% trans "Configuration information for your identity provider" %}</strong>
5
  <ul>
6
    {% filter urlize %}
7
      <li>{% trans "Metadata URL:" %} {% absolute_url 'mellon_metadata' %}</li>
8
    {% endfilter %}
9
    <li>{% trans "Expected attributes:" %}
10
      <ul>
11
        <li>{% trans "Username (username), mandatory" %}</li>
12
        <li>{% trans "Email (email), mandatory" %}</li>
13
        <li>{% trans "First name (first_name)" %}</li>
14
        <li>{% trans "Last name (last_name)" %}</li>
15
      </ul>
16
    </li>
17
    <ul>
18
    </div>
0
-