Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
saml: Set wantMessagesSigned to True only for processing LogoutRequests.
Mateusz Mandera158287f99826
diff --git a/zproject/backends.py b/zproject/backends.pyindex f0837887bdd..9748895d014 100644--- a/zproject/backends.py+++ b/zproject/backends.py@@ -2449,6 +2449,17 @@ class SAMLAuthBackend(SocialAuthMixin, SAMLAuth):"""idp = self.get_idp(idp_name)auth = self._create_saml_auth(idp)+ # This setting controls whether LogoutRequests delivered to us+ # need to be signed. The default of False is not acceptable,+ # because we don't want anyone to be able to submit a request+ # to get other users logged out.+ auth.get_settings().get_security_data()["wantMessagesSigned"] = True+ # Defensive code to confirm the setting change above is successful,+ # to catch API changes in python3-saml that would make the change not+ # be applied to the actual settings of `auth` - e.g. due to us only+ # receiving a copy of the dict.+ assert auth.get_settings().get_security_data()["wantMessagesSigned"] is True+# This validates the LogoutRequest and prepares the response# (the URL to which to redirect the client to convey the response to the IdP)# but is a no-op otherwise because keep_local_session=True keeps it fromdiff --git a/zproject/computed_settings.py b/zproject/computed_settings.pyindex e5cba89d2ed..f6fdad88705 100644--- a/zproject/computed_settings.py+++ b/zproject/computed_settings.py@@ -1129,13 +1129,6 @@ if "signatureAlgorithm" not in SOCIAL_AUTH_SAML_SECURITY_CONFIG:default_signature_alg = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"SOCIAL_AUTH_SAML_SECURITY_CONFIG["signatureAlgorithm"] = default_signature_alg-if "wantMessagesSigned" not in SOCIAL_AUTH_SAML_SECURITY_CONFIG:- # This setting controls whether LogoutRequests delivered to us- # need to be signed. The default of False is not acceptable,- # because we don't want anyone to be able to submit a request- # to get other users logged out.- SOCIAL_AUTH_SAML_SECURITY_CONFIG["wantMessagesSigned"] = True-for idp_name, idp_dict in SOCIAL_AUTH_SAML_ENABLED_IDPS.items():if DEVELOPMENT:idp_dict["entity_id"] = get_secret("saml_entity_id", "")