add declare pii view

This commit is contained in:
Paul Marillonnet 2019-05-22 09:36:49 +02:00
parent 99627f2d8e
commit a7d71f163d
4 changed files with 68 additions and 1 deletions

View File

@ -38,6 +38,7 @@ OU = get_ou_model()
class AuthorizationRuleCreateForm(forms.Form):
"""
Mockup UI for the authozitation rule creation form
todo: multiple choices charfield as radio buttons
"""
SCOPE_READ = 1
@ -67,6 +68,9 @@ class AuthorizationRuleCreateForm(forms.Form):
class RegisterClientForm(forms.Form):
"""
Mockup UI for the client registration form
"""
name = forms.CharField()
terms_of_policy = forms.CharField(widget=forms.Textarea)
terms_of_policy_url = forms.URLField()
@ -78,6 +82,41 @@ class RegisterClientForm(forms.Form):
redirection_uri_3 = forms.URLField()
class DeclarePiiForm(forms.Form):
"""
Mockup UI for the user PII declaration form
"""
ACCESS_METHOD_HTTP_GET = 1
ACCESS_METHODS_CHOICES = (
(ACCESS_METHOD_HTTP_GET, "HTTP GET"),
)
AUTHORIZATION_METHOD_OAUTH_UMA = 1
AUTHORIZATION_METHODS_CHOICES = (
(AUTHORIZATION_METHOD_OAUTH_UMA, "OAuth 2.0 with UMA profile"),
)
AUTHZ_SERVER_USER_AUTHN_METHOD_HTTP_BASIC_LOGIN_PASSWD = 1
AUTHZ_SERVER_USER_AUTHN_METHODS_CHOICES = (
(AUTHZ_SERVER_USER_AUTHN_METHOD_HTTP_BASIC_LOGIN_PASSWD,
"User login/password on HTTP Basic"),
)
PII_FORMAT_JSON_PATH = 1
PII_FORMATS_CHOICES = (
(PII_FORMAT_JSON_PATH, "JSON Path"),
)
access_method = forms.ChoiceField(choices=ACCESS_METHODS_CHOICES)
pii_url = forms.CharField()
authorization = forms.ChoiceField(choices=AUTHORIZATION_METHODS_CHOICES)
authz_server_permission_ticket_url = forms.CharField()
authz_server_token_endpoint_url = forms.CharField()
authz_server_user_authn_method = forms.ChoiceField(
choices=AUTHZ_SERVER_USER_AUTHN_METHODS_CHOICES
)
login_url = forms.CharField()
logout_url = forms.CharField()
pii_format = forms.ChoiceField(choices=PII_FORMATS_CHOICES)
json_path = forms.CharField()
class EmailChangeFormNoPassword(forms.Form):
email = forms.EmailField(label=_('New email'))

View File

@ -10,7 +10,7 @@ from django.views.decorators.debug import sensitive_post_parameters
from authentic2.utils import import_module_or_class, redirect
from . import app_settings, decorators, profile_views, hooks
from .views import (logged_in, edit_profile, email_change, email_change_verify, profile,
authorization_rule_create_view, register_client_view)
authorization_rule_create_view, register_client_view, declare_pii_view)
SET_PASSWORD_FORM_CLASS = import_module_or_class(
app_settings.A2_REGISTRATION_SET_PASSWORD_FORM_CLASS)
@ -99,4 +99,5 @@ urlpatterns = [
authorization_rule_create_view,
name='a2-authz-rule-create'),
url(r'^register-client/$', register_client_view, name='a2-regiser-client'),
url(r'^declare-pii/$', declare_pii_view, name='a2-declare-pii'),
]

View File

@ -0,0 +1,19 @@
{% extends "authentic2/base-page.html" %}
{% load i18n %}
{% block page-title %}
{{ block.super }} - {{ view.title }}
{% endblock %}
{% block breadcrumb %}
<a href="">{{ view.title }}</a>
{% endblock %}
{% block content %}
<form enctype="multipart/form-data" method="post">
{% csrf_token %}
{{ form.as_p }}
<button class="submit-button">{% trans "Register" %}</button>
</form>
{% endblock %}

View File

@ -65,6 +65,14 @@ class RegisterClientView(FormView):
register_client_view = login_required(RegisterClientView.as_view())
class DeclarePiiView(FormView):
form_class = forms.DeclarePiiForm
template_name = "authentic2/declare_pii.html"
title = _('Declare PII')
declare_pii_view = login_required(DeclarePiiView.as_view())
def redirect(request, next, template_name='redirect.html'):
'''Show a simple page which does a javascript redirect, closing any popup
enclosing us'''