providers/saml: Show error message when trying to get metadata without assigning application
This commit is contained in:
parent
b290bbf6d7
commit
e0272a6422
|
@ -17,7 +17,7 @@ from signxml.util import strip_pem_header
|
||||||
from structlog import get_logger
|
from structlog import get_logger
|
||||||
|
|
||||||
from passbook.audit.models import Event, EventAction
|
from passbook.audit.models import Event, EventAction
|
||||||
from passbook.core.models import Application
|
from passbook.core.models import Application, Provider
|
||||||
from passbook.lib.utils.template import render_to_string
|
from passbook.lib.utils.template import render_to_string
|
||||||
from passbook.lib.views import bad_request_message
|
from passbook.lib.views import bad_request_message
|
||||||
from passbook.policies.engine import PolicyEngine
|
from passbook.policies.engine import PolicyEngine
|
||||||
|
@ -253,12 +253,18 @@ class DescriptorDownloadView(AccessRequiredView):
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
def get(self, request: HttpRequest, application: str) -> HttpResponse:
|
def get(self, request: HttpRequest, application: str) -> HttpResponse:
|
||||||
"""Replies with the XML Metadata IDSSODescriptor."""
|
"""Replies with the XML Metadata IDSSODescriptor."""
|
||||||
metadata = DescriptorDownloadView.get_metadata(request, self.provider)
|
try:
|
||||||
response = HttpResponse(metadata, content_type="application/xml")
|
metadata = DescriptorDownloadView.get_metadata(request, self.provider)
|
||||||
response["Content-Disposition"] = (
|
except Provider.application.RelatedObjectDoesNotExist: # pylint: disable=no-member
|
||||||
'attachment; filename="' '%s_passbook_meta.xml"' % self.provider.name
|
return bad_request_message(
|
||||||
)
|
request, "Provider is not assigned to an application."
|
||||||
return response
|
)
|
||||||
|
else:
|
||||||
|
response = HttpResponse(metadata, content_type="application/xml")
|
||||||
|
response["Content-Disposition"] = (
|
||||||
|
'attachment; filename="' '%s_passbook_meta.xml"' % self.provider.name
|
||||||
|
)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
class InitiateLoginView(AccessRequiredView):
|
class InitiateLoginView(AccessRequiredView):
|
||||||
|
|
Reference in New Issue