diff options
author | Neil Johnson <neil@matrix.org> | 2018-08-08 12:44:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-08 12:44:15 +0000 |
commit | 990fe9fc23245d193233b88f924e905ee4b2de3d (patch) | |
tree | bc5aed8a97fdd22845ec48e5c84fea981f812003 /synapse/api/auth.py | |
parent | Merge pull request #3658 from matrix-org/rav/fix_event_persisted_position_met... (diff) | |
parent | typos (diff) | |
download | synapse-990fe9fc23245d193233b88f924e905ee4b2de3d.tar.xz |
Merge pull request #3633 from matrix-org/neilj/mau_tracker
API for monthly_active_users table
Diffstat (limited to 'synapse/api/auth.py')
-rw-r--r-- | synapse/api/auth.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py index 5bbbe8e2e7..91b23ff1d7 100644 --- a/synapse/api/auth.py +++ b/synapse/api/auth.py @@ -213,7 +213,7 @@ class Auth(object): default=[b""] )[0] if user and access_token and ip_addr: - self.store.insert_client_ip( + yield self.store.insert_client_ip( user_id=user.to_string(), access_token=access_token, ip=ip_addr, @@ -773,3 +773,15 @@ class Auth(object): raise AuthError( 403, "Guest access not allowed", errcode=Codes.GUEST_ACCESS_FORBIDDEN ) + + @defer.inlineCallbacks + def check_auth_blocking(self): + """Checks if the user should be rejected for some external reason, + such as monthly active user limiting or global disable flag + """ + 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 AuthError( + 403, "MAU Limit Exceeded", errcode=Codes.MAU_LIMIT_EXCEEDED + ) |