From d8315996084f3375a5919c957ff473421427e2c7 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 8 Jul 2020 14:27:32 +0200 Subject: [PATCH] core: make autosubmit_form generic template --- .../templates/generic}/autosubmit_form.html | 4 +--- passbook/providers/saml/views.py | 5 +++-- passbook/sources/saml/forms.py | 2 +- .../saml/migrations/0004_auto_20200708_1207.py | 16 ++++++++++++---- passbook/sources/saml/views.py | 10 ++++------ swagger.yaml | 1 + 6 files changed, 22 insertions(+), 16 deletions(-) rename passbook/{providers/saml/templates/providers/saml => core/templates/generic}/autosubmit_form.html (92%) diff --git a/passbook/providers/saml/templates/providers/saml/autosubmit_form.html b/passbook/core/templates/generic/autosubmit_form.html similarity index 92% rename from passbook/providers/saml/templates/providers/saml/autosubmit_form.html rename to passbook/core/templates/generic/autosubmit_form.html index 489e00f55..687e76565 100644 --- a/passbook/providers/saml/templates/providers/saml/autosubmit_form.html +++ b/passbook/core/templates/generic/autosubmit_form.html @@ -4,9 +4,7 @@ {% load i18n %} {% block title %} -{% blocktrans with app=application.name %} -Redirecting to {{ app }}... -{% endblocktrans %} +{{ title }} {% endblock %} {% block card %} diff --git a/passbook/providers/saml/views.py b/passbook/providers/saml/views.py index f2c55d0f6..ba74d31d2 100644 --- a/passbook/providers/saml/views.py +++ b/passbook/providers/saml/views.py @@ -7,6 +7,7 @@ from django.http import HttpRequest, HttpResponse from django.shortcuts import get_object_or_404, redirect, render, reverse from django.utils.decorators import method_decorator from django.utils.http import urlencode +from django.utils.translation import gettext_lazy as _ from django.views import View from django.views.decorators.csrf import csrf_exempt from signxml.util import strip_pem_header @@ -190,10 +191,10 @@ class SAMLFlowFinalView(StageView): if provider.sp_binding == SAMLBindings.POST: return render( self.request, - "providers/saml/autosubmit_form.html", + "generic/autosubmit_form.html", { "url": response.acs_url, - "application": application, + "title": _("Redirecting to %(app)s..." % {"app": application.name}), "attrs": { "ACSUrl": response.acs_url, SESSION_KEY_SAML_RESPONSE: response.saml_response, diff --git a/passbook/sources/saml/forms.py b/passbook/sources/saml/forms.py index 8e7116b76..413b8e9bc 100644 --- a/passbook/sources/saml/forms.py +++ b/passbook/sources/saml/forms.py @@ -2,8 +2,8 @@ from django import forms -from passbook.flows.models import Flow, FlowDesignation from passbook.admin.forms.source import SOURCE_FORM_FIELDS +from passbook.flows.models import Flow, FlowDesignation from passbook.sources.saml.models import SAMLSource diff --git a/passbook/sources/saml/migrations/0004_auto_20200708_1207.py b/passbook/sources/saml/migrations/0004_auto_20200708_1207.py index 4034293eb..7fca92683 100644 --- a/passbook/sources/saml/migrations/0004_auto_20200708_1207.py +++ b/passbook/sources/saml/migrations/0004_auto_20200708_1207.py @@ -6,13 +6,21 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('passbook_sources_saml', '0003_auto_20200624_1957'), + ("passbook_sources_saml", "0003_auto_20200624_1957"), ] operations = [ migrations.AlterField( - model_name='samlsource', - name='binding_type', - field=models.CharField(choices=[('REDIRECT', 'Redirect Binding'), ('POST', 'POST Binding'), ('POST_AUTO', 'POST Binding with auto-confirmation')], default='REDIRECT', max_length=100), + model_name="samlsource", + name="binding_type", + field=models.CharField( + choices=[ + ("REDIRECT", "Redirect Binding"), + ("POST", "POST Binding"), + ("POST_AUTO", "POST Binding with auto-confirmation"), + ], + default="REDIRECT", + max_length=100, + ), ), ] diff --git a/passbook/sources/saml/views.py b/passbook/sources/saml/views.py index beb9728e0..f734ea5c5 100644 --- a/passbook/sources/saml/views.py +++ b/passbook/sources/saml/views.py @@ -5,6 +5,7 @@ from django.http import Http404, HttpRequest, HttpResponse from django.shortcuts import get_object_or_404, redirect, render from django.utils.decorators import method_decorator from django.utils.http import urlencode +from django.utils.translation import gettext_lazy as _ from django.views import View from django.views.decorators.csrf import csrf_exempt from signxml import InvalidSignature @@ -64,13 +65,10 @@ class InitiateView(View): if source.binding_type == SAMLBindingTypes.POST_AUTO: return render( request, - "providers/saml/autosubmit_form.html", + "generic/autosubmit_form.html", { - "application": source, - "attrs": { - "SAMLRequest": _request, - "RelayState": relay_state, - }, + "title": _("Redirecting to %(app)s..." % {"app": source.name}), + "attrs": {"SAMLRequest": _request, "RelayState": relay_state}, "url": source.sso_url, }, ) diff --git a/swagger.yaml b/swagger.yaml index bf7a60faf..18c119571 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -6511,6 +6511,7 @@ definitions: enum: - REDIRECT - POST + - POST_AUTO slo_url: title: SLO URL description: Optional URL if your IDP supports Single-Logout.