all: general maintenance, prepare for pyright
This commit is contained in:
@ -21,13 +21,15 @@ class SAMLSource(Source):
|
||||
|
||||
@property
|
||||
def login_button(self):
|
||||
url = reverse_lazy("passbook_sources_saml:login", kwargs={"source": self.slug})
|
||||
url = reverse_lazy(
|
||||
"passbook_sources_saml:login", kwargs={"source_slug": self.slug}
|
||||
)
|
||||
return url, "", self.name
|
||||
|
||||
@property
|
||||
def additional_info(self):
|
||||
metadata_url = reverse_lazy(
|
||||
"passbook_sources_saml:metadata", kwargs={"source": self}
|
||||
"passbook_sources_saml:metadata", kwargs={"source_slug": self}
|
||||
)
|
||||
return f'<a href="{metadata_url}" class="btn btn-default btn-sm">Metadata Download</a>'
|
||||
|
||||
|
||||
@ -4,8 +4,8 @@ from django.urls import path
|
||||
from passbook.sources.saml.views import ACSView, InitiateView, MetadataView, SLOView
|
||||
|
||||
urlpatterns = [
|
||||
path("<slug:source>/", InitiateView.as_view(), name="login"),
|
||||
path("<slug:source>/acs/", ACSView.as_view(), name="acs"),
|
||||
path("<slug:source>/slo/", SLOView.as_view(), name="slo"),
|
||||
path("<slug:source>/metadata/", MetadataView.as_view(), name="metadata"),
|
||||
path("<slug:source_slug>/", InitiateView.as_view(), name="login"),
|
||||
path("<slug:source_slug>/acs/", ACSView.as_view(), name="acs"),
|
||||
path("<slug:source_slug>/slo/", SLOView.as_view(), name="slo"),
|
||||
path("<slug:source_slug>/metadata/", MetadataView.as_view(), name="metadata"),
|
||||
]
|
||||
|
||||
@ -24,9 +24,9 @@ from passbook.sources.saml.xml_render import get_authnrequest_xml
|
||||
class InitiateView(View):
|
||||
"""Get the Form with SAML Request, which sends us to the IDP"""
|
||||
|
||||
def get(self, request: HttpRequest, source: str) -> HttpResponse:
|
||||
def get(self, request: HttpRequest, source_slug: str) -> HttpResponse:
|
||||
"""Replies with an XHTML SSO Request."""
|
||||
source: SAMLSource = get_object_or_404(SAMLSource, slug=source)
|
||||
source: SAMLSource = get_object_or_404(SAMLSource, slug=source_slug)
|
||||
if not source.enabled:
|
||||
raise Http404
|
||||
sso_destination = request.GET.get("next", None)
|
||||
@ -56,9 +56,9 @@ class InitiateView(View):
|
||||
class ACSView(View):
|
||||
"""AssertionConsumerService, consume assertion and log user in"""
|
||||
|
||||
def post(self, request: HttpRequest, source: str) -> HttpResponse:
|
||||
def post(self, request: HttpRequest, source_slug: str) -> HttpResponse:
|
||||
"""Handles a POSTed SSO Assertion and logs the user in."""
|
||||
source: SAMLSource = get_object_or_404(SAMLSource, slug=source)
|
||||
source: SAMLSource = get_object_or_404(SAMLSource, slug=source_slug)
|
||||
if not source.enabled:
|
||||
raise Http404
|
||||
# sso_session = request.POST.get('RelayState', None)
|
||||
@ -74,9 +74,9 @@ class ACSView(View):
|
||||
class SLOView(View):
|
||||
"""Single-Logout-View"""
|
||||
|
||||
def dispatch(self, request: HttpRequest, source: str) -> HttpResponse:
|
||||
def dispatch(self, request: HttpRequest, source_slug: str) -> HttpResponse:
|
||||
"""Replies with an XHTML SSO Request."""
|
||||
source: SAMLSource = get_object_or_404(SAMLSource, slug=source)
|
||||
source: SAMLSource = get_object_or_404(SAMLSource, slug=source_slug)
|
||||
if not source.enabled:
|
||||
raise Http404
|
||||
logout(request)
|
||||
@ -93,9 +93,9 @@ class SLOView(View):
|
||||
class MetadataView(View):
|
||||
"""Return XML Metadata for IDP"""
|
||||
|
||||
def dispatch(self, request: HttpRequest, source: str) -> HttpResponse:
|
||||
def dispatch(self, request: HttpRequest, source_slug: str) -> HttpResponse:
|
||||
"""Replies with the XML Metadata SPSSODescriptor."""
|
||||
source: SAMLSource = get_object_or_404(SAMLSource, slug=source)
|
||||
source: SAMLSource = get_object_or_404(SAMLSource, slug=source_slug)
|
||||
entity_id = get_entity_id(request, source)
|
||||
return render_xml(
|
||||
request,
|
||||
|
||||
Reference in New Issue
Block a user