From eb3165f8e75decab42b6362502e46941d2107d23 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 15 Dec 2021 19:53:30 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20saml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/backends/saml2/views.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/authentication/backends/saml2/views.py b/apps/authentication/backends/saml2/views.py index f1affb8af..4ce812fe8 100644 --- a/apps/authentication/backends/saml2/views.py +++ b/apps/authentication/backends/saml2/views.py @@ -270,7 +270,7 @@ class Saml2AuthCallbackView(View, PrepareRequestMixin): class Saml2AuthMetadataView(View, PrepareRequestMixin): - def get(self, _): + def get(self, request): saml_settings = self.get_sp_settings() saml_settings = JmsSaml2Settings( settings=saml_settings, sp_validation_only=True, @@ -279,8 +279,17 @@ class Saml2AuthMetadataView(View, PrepareRequestMixin): metadata = saml_settings.get_sp_metadata() errors = saml_settings.validate_metadata(metadata) + key = saml_settings.get_sp_key() + cert = saml_settings.get_sp_cert() + if not key: + errors.append('Not found SP private key') + if not cert: + errors.append('Not found SP cert') + if len(errors) == 0: resp = HttpResponse(content=metadata, content_type='text/xml') else: - resp = HttpResponseServerError(content=', '.join(errors)) + content = "Error occur:
" + content += '
'.join(errors) + resp = HttpResponseServerError(content=content) return resp