summary refs log tree commit diff
path: root/synapse/api/auth.py
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2015-02-06 10:57:14 +0000
committerKegan Dougal <kegan@matrix.org>2015-02-06 10:57:14 +0000
commite426df8e106aef0b213928afb6189569474ac5d9 (patch)
treecc3d87ba7b4da572afe2f76c644b1330a6d82001 /synapse/api/auth.py
parentAdd m.login.application_service registration procedure. (diff)
downloadsynapse-e426df8e106aef0b213928afb6189569474ac5d9.tar.xz
Grant ASes the ability to create alias in their own namespace.
Add a new errcode type M_EXCLUSIVE when users try to create aliases inside
AS namespaces, and when ASes try to create aliases outside their own
namespace.
Diffstat (limited to 'synapse/api/auth.py')
-rw-r--r--synapse/api/auth.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index 4f116184c9..ea8c461729 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -380,6 +380,18 @@ class Auth(object):
             raise AuthError(403, "Unrecognised access token.",
                             errcode=Codes.UNKNOWN_TOKEN)
 
+    @defer.inlineCallbacks
+    def get_appservice_by_req(self, request):
+        try:
+            token = request.args["access_token"][0]
+            service = yield self.store.get_app_service_by_token(token)
+            if not service:
+                raise AuthError(403, "Unrecognised access token.",
+                                errcode=Codes.UNKNOWN_TOKEN)
+            defer.returnValue(service)
+        except KeyError:
+            raise AuthError(403, "Missing access token.")
+
     def is_server_admin(self, user):
         return self.store.is_server_admin(user)