providers/saml: Show error message when trying to get metadata without assigning application
This commit is contained in:
		| @ -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,7 +253,13 @@ 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.""" | ||||||
|  |         try: | ||||||
|             metadata = DescriptorDownloadView.get_metadata(request, self.provider) |             metadata = DescriptorDownloadView.get_metadata(request, self.provider) | ||||||
|  |         except Provider.application.RelatedObjectDoesNotExist:  # pylint: disable=no-member | ||||||
|  |             return bad_request_message( | ||||||
|  |                 request, "Provider is not assigned to an application." | ||||||
|  |             ) | ||||||
|  |         else: | ||||||
|             response = HttpResponse(metadata, content_type="application/xml") |             response = HttpResponse(metadata, content_type="application/xml") | ||||||
|             response["Content-Disposition"] = ( |             response["Content-Disposition"] = ( | ||||||
|                 'attachment; filename="' '%s_passbook_meta.xml"' % self.provider.name |                 'attachment; filename="' '%s_passbook_meta.xml"' % self.provider.name | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer