summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2018-06-28 20:31:53 +0100
committerMatthew Hodgson <matthew@matrix.org>2018-06-28 20:32:00 +0100
commitf4f1cda928911197332a9a8bffcfb67c2b5b81e4 (patch)
tree0e503f9ad56153962096540b3c1a56b18359b0d2 /synapse/api
parentAttempt to be more performant on PyPy (#3462) (diff)
downloadsynapse-f4f1cda928911197332a9a8bffcfb67c2b5b81e4.tar.xz
add ip_range_whitelist parameter to limit where ASes can connect from
Diffstat (limited to 'synapse/api')
-rw-r--r--synapse/api/auth.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index 54186695cd..088b4e8b6d 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -19,6 +19,7 @@ from six import itervalues
 
 import pymacaroons
 from twisted.internet import defer
+from netaddr import IPAddress
 
 import synapse.types
 from synapse import event_auth
@@ -244,6 +245,11 @@ class Auth(object):
         if app_service is None:
             defer.returnValue((None, None))
 
+        if app_service.ip_range_whitelist:
+            ip_address = IPAddress(self.hs.get_ip_from_request(request))
+            if ip_address not in app_service.ip_range_whitelist:
+                defer.returnValue((None, None))
+
         if "user_id" not in request.args:
             defer.returnValue((app_service.sender, app_service))