summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorSteven Hammerton <steven.hammerton@openmarket.com>2015-10-12 15:05:34 +0100
committerSteven Hammerton <steven.hammerton@openmarket.com>2015-10-12 15:05:34 +0100
commit83b464e4f70fbfcc338b0c3533359a8c53890cdc (patch)
tree87c7c646c0c249bee196511d0848eb2afbd4bc10 /synapse
parentDefault cas_required_attributes to empty dictionary (diff)
downloadsynapse-83b464e4f70fbfcc338b0c3533359a8c53890cdc.tar.xz
Unpack dictionary in for loop for nicer syntax
Diffstat (limited to 'synapse')
-rw-r--r--synapse/rest/client/v1/login.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/synapse/rest/client/v1/login.py b/synapse/rest/client/v1/login.py
index 8facb00126..c92dedcc0f 100644
--- a/synapse/rest/client/v1/login.py
+++ b/synapse/rest/client/v1/login.py
@@ -127,16 +127,16 @@ class LoginRestServlet(ClientV1RestServlet):
     def do_cas_login(self, cas_response_body):
         user, attributes = self.parse_cas_response(cas_response_body)
 
-        for required_attribute in self.cas_required_attributes:
+        for required_attribute, required_value in self.cas_required_attributes.items():
             # If required attribute was not in CAS Response - Forbidden
             if required_attribute not in attributes:
                 raise LoginError(401, "Unauthorized", errcode=Codes.UNAUTHORIZED)
 
             # Also need to check value
-            if self.cas_required_attributes[required_attribute] is not None:
-                actualValue = attributes[required_attribute]
+            if required_value is not None:
+                actual_value = attributes[required_attribute]
                 # If required attribute value does not match expected - Forbidden
-                if self.cas_required_attributes[required_attribute] != actualValue:
+                if required_value != actual_value:
                     raise LoginError(401, "Unauthorized", errcode=Codes.UNAUTHORIZED)
 
         user_id = UserID.create(user, self.hs.hostname).to_string()