summary refs log tree commit diff
path: root/synapse/api/auth.py
diff options
context:
space:
mode:
authorDaniel Wagner-Hall <daniel@matrix.org>2016-01-11 15:29:57 +0000
committerDaniel Wagner-Hall <daniel@matrix.org>2016-01-11 17:48:45 +0000
commit2110e35fd6e50aa7c44410601c7e5e938c912c3e (patch)
tree825cfc5c59aa6e60064b56dce920b6429437d7e5 /synapse/api/auth.py
parentUse logger not logging (diff)
downloadsynapse-2110e35fd6e50aa7c44410601c7e5e938c912c3e.tar.xz
Introduce a Requester object
This tracks data about the entity which made the request. This is
instead of passing around a tuple, which requires call-site
modifications every time a new piece of optional context is passed
around.

I tried to introduce a User object. I gave up.
Diffstat (limited to 'synapse/api/auth.py')
-rw-r--r--synapse/api/auth.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index b86c6c8399..876869bb74 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -22,7 +22,7 @@ from twisted.internet import defer
 
 from synapse.api.constants import EventTypes, Membership, JoinRules
 from synapse.api.errors import AuthError, Codes, SynapseError, EventSizeError
-from synapse.types import RoomID, UserID, EventID
+from synapse.types import Requester, RoomID, UserID, EventID
 from synapse.util.logutils import log_function
 from unpaddedbase64 import decode_base64
 
@@ -534,7 +534,9 @@ class Auth(object):
 
                 request.authenticated_entity = user_id
 
-                defer.returnValue((UserID.from_string(user_id), "", False))
+                defer.returnValue(
+                    Requester(UserID.from_string(user_id), "", False)
+                )
                 return
             except KeyError:
                 pass  # normal users won't have the user_id query parameter set.
@@ -564,7 +566,7 @@ class Auth(object):
 
             request.authenticated_entity = user.to_string()
 
-            defer.returnValue((user, token_id, is_guest,))
+            defer.returnValue(Requester(user, token_id, is_guest))
         except KeyError:
             raise AuthError(
                 self.TOKEN_NOT_FOUND_HTTP_STATUS, "Missing access token.",