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.

scim: Use setattr to set request.user as scim_client.

Zixuan James Lia20c9ea28dfb
diff --git a/zerver/middleware.py b/zerver/middleware.py
index 21250c6e286..db72b3d1a97 100644
--- a/zerver/middleware.py
+++ b/zerver/middleware.py
@@ -786,5 +786,7 @@ class ZulipSCIMAuthCheckMiddleware(SCIMAuthCheckMiddleware):
# so we can assign the corresponding SCIMClient object to request.user - which
# will allow this request to pass request.user.is_authenticated checks from now on,
# to be served by the relevant views implemented in django-scim2.
- request.user = scim_client
+ # Since request.user must be a UserProfile or AnonymousUser, setattr is a type-unsafe
+ # workaround to make this monkey-patching work.
+ setattr(request, "user", scim_client)
return None