summary refs log tree commit diff
path: root/synapse/api/auth.py
diff options
context:
space:
mode:
authorNeil Johnson <neil@matrix.org>2018-08-02 16:57:35 +0100
committerNeil Johnson <neil@matrix.org>2018-08-02 16:57:35 +0100
commit74b1d46ad9ae692774f2e9d71cbbe1cea91b4070 (patch)
treed1790607bc3a8ae00db9cfa57efd79bf3fedaac1 /synapse/api/auth.py
parentremove unused count_monthly_users (diff)
downloadsynapse-74b1d46ad9ae692774f2e9d71cbbe1cea91b4070.tar.xz
do mau checks based on monthly_active_users table
Diffstat (limited to 'synapse/api/auth.py')
-rw-r--r--synapse/api/auth.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index d8022bcf8e..943a488339 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -773,3 +773,16 @@ class Auth(object):
             raise AuthError(
                 403, "Guest access not allowed", errcode=Codes.GUEST_ACCESS_FORBIDDEN
             )
+
+    @defer.inlineCallbacks
+    def check_auth_blocking(self, error):
+        """Checks if the user should be rejected for some external reason,
+        such as monthly active user limiting or global disable flag
+        Args:
+            error (Error): The error that should be raised if user is to be
+            blocked
+            """
+        if self.hs.config.limit_usage_by_mau is True:
+            current_mau = yield self.store.get_monthly_active_count()
+            if current_mau >= self.hs.config.max_mau_value:
+                raise error