core: make EndSessionView inherit PolicyAccessView

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-06-06 14:07:50 +02:00
parent b55c3a687d
commit 90a5c84ac8
3 changed files with 19 additions and 15 deletions

View File

@ -1,5 +1,4 @@
"""authentik URL Configuration""" """authentik URL Configuration"""
from authentik.core.views.session import EndSessionView
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.urls import path from django.urls import path
from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.csrf import ensure_csrf_cookie
@ -8,6 +7,7 @@ from django.views.generic.base import TemplateView
from authentik.core.views import impersonate from authentik.core.views import impersonate
from authentik.core.views.interface import FlowInterfaceView from authentik.core.views.interface import FlowInterfaceView
from authentik.core.views.session import EndSessionView
urlpatterns = [ urlpatterns = [
path( path(

View File

@ -5,18 +5,20 @@ from django.shortcuts import get_object_or_404
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from authentik.core.models import Application from authentik.core.models import Application
from authentik.policies.views import PolicyAccessView
class EndSessionView(TemplateView): class EndSessionView(TemplateView, PolicyAccessView):
"""Allow the client to end the Session""" """Allow the client to end the Session"""
template_name = "if/end_session.html" template_name = "if/end_session.html"
def get_context_data(self, **kwargs: Any) -> dict[str, Any]: def resolve_provider_application(self):
context = super().get_context_data(**kwargs) self.application = get_object_or_404(
context["application"] = get_object_or_404(
Application, slug=self.kwargs["application_slug"] Application, slug=self.kwargs["application_slug"]
) )
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
context["application"] = self.application
return context return context

View File

@ -27,6 +27,7 @@
{% endif %} {% endif %}
{% if policy_result %} {% if policy_result %}
<hr> <hr>
{% if policy_result.messages %}
<em>{% trans 'Messages:' %}</em> <em>{% trans 'Messages:' %}</em>
<ul class="pf-c-list"> <ul class="pf-c-list">
{% for message in policy_result.messages %} {% for message in policy_result.messages %}
@ -35,6 +36,7 @@
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %}
{% if policy_result.source_results %} {% if policy_result.source_results %}
<em>{% trans 'Explanation:' %}</em> <em>{% trans 'Explanation:' %}</em>
<ul class="pf-c-list"> <ul class="pf-c-list">