providers/saml: fix Error when getting metadata for invalid ID
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
a64dbc94c1
commit
d70b81fe43
|
@ -3,7 +3,6 @@ from xml.etree.ElementTree import ParseError # nosec
|
||||||
|
|
||||||
from defusedxml.ElementTree import fromstring
|
from defusedxml.ElementTree import fromstring
|
||||||
from django.http.response import HttpResponse
|
from django.http.response import HttpResponse
|
||||||
from django.shortcuts import get_object_or_404
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from drf_spectacular.types import OpenApiTypes
|
from drf_spectacular.types import OpenApiTypes
|
||||||
|
@ -115,8 +114,7 @@ class SAMLProviderViewSet(UsedByMixin, ModelViewSet):
|
||||||
# pylint: disable=invalid-name, unused-argument
|
# pylint: disable=invalid-name, unused-argument
|
||||||
def metadata(self, request: Request, pk: int) -> Response:
|
def metadata(self, request: Request, pk: int) -> Response:
|
||||||
"""Return metadata as XML string"""
|
"""Return metadata as XML string"""
|
||||||
# We don't use self.get_object() on purpose as this view is un-authenticated
|
provider = self.get_object()
|
||||||
provider = get_object_or_404(SAMLProvider, pk=pk)
|
|
||||||
try:
|
try:
|
||||||
metadata = MetadataProcessor(provider, request).build_entity_descriptor()
|
metadata = MetadataProcessor(provider, request).build_entity_descriptor()
|
||||||
if "download" in request._request.GET:
|
if "download" in request._request.GET:
|
||||||
|
|
Reference in a new issue