Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

saml: Add defensive code against org_membership attr not being a list.

Mateusz Manderaa0dea84edb88
diff --git a/zproject/backends.py b/zproject/backends.py
index 47021af8d5e..8c657aba0d3 100644
--- a/zproject/backends.py
+++ b/zproject/backends.py
@@ -1844,6 +1844,12 @@ class SAMLAuthBackend(SocialAuthMixin, SAMLAuth):
subdomain = self.strategy.session_get('subdomain')
entitlements: Union[str, List[str]] = attributes.get(org_membership_attribute, [])
+ if isinstance(entitlements, str): # nocoverage
+ # This shouldn't happen as we'd always expect a list from this attribute even
+ # if it only has one element, but it's safer to have this defensive code.
+ entitlements = [entitlements, ]
+ assert isinstance(entitlements, list)
+
if subdomain in entitlements:
return