summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
authorLuke Barnard <lukebarnard1@users.noreply.github.com>2016-10-20 16:21:10 +0100
committerGitHub <noreply@github.com>2016-10-20 16:21:10 +0100
commite01a1bc92d907a2bbbb67b4cf9e57e992a2ab91c (patch)
tree57cd35aa57f91102045b694fcaee98be1fee95cb /synapse/api
parentMerge pull request #1164 from pik/error-codes (diff)
parentStyle (diff)
downloadsynapse-e01a1bc92d907a2bbbb67b4cf9e57e992a2ab91c.tar.xz
Merge pull request #1175 from matrix-org/luke/feature-configurable-as-rate-limiting
Allow Configurable Rate Limiting Per AS
Diffstat (limited to 'synapse/api')
-rw-r--r--synapse/api/auth.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index 1b3b55d517..b6a151a7ec 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -603,10 +603,12 @@ class Auth(object):
         """
         # Can optionally look elsewhere in the request (e.g. headers)
         try:
-            user_id = yield self._get_appservice_user_id(request)
+            user_id, app_service = yield self._get_appservice_user_id(request)
             if user_id:
                 request.authenticated_entity = user_id
-                defer.returnValue(synapse.types.create_requester(user_id))
+                defer.returnValue(
+                    synapse.types.create_requester(user_id, app_service=app_service)
+                )
 
             access_token = get_access_token_from_request(
                 request, self.TOKEN_NOT_FOUND_HTTP_STATUS
@@ -644,7 +646,8 @@ class Auth(object):
             request.authenticated_entity = user.to_string()
 
             defer.returnValue(synapse.types.create_requester(
-                user, token_id, is_guest, device_id))
+                user, token_id, is_guest, device_id, app_service=app_service)
+            )
         except KeyError:
             raise AuthError(
                 self.TOKEN_NOT_FOUND_HTTP_STATUS, "Missing access token.",
@@ -659,14 +662,14 @@ class Auth(object):
             )
         )
         if app_service is None:
-            defer.returnValue(None)
+            defer.returnValue((None, None))
 
         if "user_id" not in request.args:
-            defer.returnValue(app_service.sender)
+            defer.returnValue((app_service.sender, app_service))
 
         user_id = request.args["user_id"][0]
         if app_service.sender == user_id:
-            defer.returnValue(app_service.sender)
+            defer.returnValue((app_service.sender, app_service))
 
         if not app_service.is_interested_in_user(user_id):
             raise AuthError(
@@ -678,7 +681,7 @@ class Auth(object):
                 403,
                 "Application service has not registered this user"
             )
-        defer.returnValue(user_id)
+        defer.returnValue((user_id, app_service))
 
     @defer.inlineCallbacks
     def get_user_by_access_token(self, token, rights="access"):