From 29fe731bbf38c07dd89b595c83c169be3326f1c5 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 1 Aug 2021 13:50:54 +0200 Subject: [PATCH] providers/saml: fix Error when getting metadata for invalid ID Signed-off-by: Jens Langhammer --- authentik/providers/saml/api.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/authentik/providers/saml/api.py b/authentik/providers/saml/api.py index a5cdcf6c7..ba2ff33e6 100644 --- a/authentik/providers/saml/api.py +++ b/authentik/providers/saml/api.py @@ -3,7 +3,6 @@ from xml.etree.ElementTree import ParseError # nosec from defusedxml.ElementTree import fromstring from django.http.response import HttpResponse -from django.shortcuts import get_object_or_404 from django.urls import reverse from django.utils.translation import gettext_lazy as _ from drf_spectacular.types import OpenApiTypes @@ -115,8 +114,7 @@ class SAMLProviderViewSet(UsedByMixin, ModelViewSet): # pylint: disable=invalid-name, unused-argument def metadata(self, request: Request, pk: int) -> Response: """Return metadata as XML string""" - # We don't use self.get_object() on purpose as this view is un-authenticated - provider = get_object_or_404(SAMLProvider, pk=pk) + provider = self.get_object() try: metadata = MetadataProcessor(provider, request).build_entity_descriptor() if "download" in request._request.GET: