summary refs log tree commit diff
path: root/synapse/api/auth.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2019-05-02 13:37:35 +0100
committerRichard van der Hoff <richard@matrix.org>2019-05-02 13:37:35 +0100
commit746773883438ccbb67ba307031afa96e883f43cb (patch)
treecabf8acccd29d969d267b26f8f53e8c33ce38b95 /synapse/api/auth.py
parentMerge branch 'erikj/ratelimit_3pid_invite' of github.com:matrix-org/synapse i... (diff)
parentAdd admin api for sending server_notices (#5121) (diff)
downloadsynapse-746773883438ccbb67ba307031afa96e883f43cb.tar.xz
Merge remote-tracking branch 'origin/develop' into matrix-org-hotfixes
Diffstat (limited to 'synapse/api/auth.py')
-rw-r--r--synapse/api/auth.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py

index e8112d5f05..0c6c93a87b 100644 --- a/synapse/api/auth.py +++ b/synapse/api/auth.py
@@ -64,6 +64,8 @@ class Auth(object): self.token_cache = LruCache(CACHE_SIZE_FACTOR * 10000) register_cache("cache", "token_cache", self.token_cache) + self._account_validity = hs.config.account_validity + @defer.inlineCallbacks def check_from_context(self, room_version, event, context, do_sig_check=True): prev_state_ids = yield context.get_prev_state_ids(self.store) @@ -226,6 +228,17 @@ class Auth(object): token_id = user_info["token_id"] is_guest = user_info["is_guest"] + # Deny the request if the user account has expired. + if self._account_validity.enabled: + user_id = user.to_string() + expiration_ts = yield self.store.get_expiration_ts_for_user(user_id) + if expiration_ts is not None and self.clock.time_msec() >= expiration_ts: + raise AuthError( + 403, + "User account has expired", + errcode=Codes.EXPIRED_ACCOUNT, + ) + # device_id may not be present if get_user_by_access_token has been # stubbed out. device_id = user_info.get("device_id") @@ -543,7 +556,7 @@ class Auth(object): """ Check if the given user is a local server admin. Args: - user (str): mxid of user to check + user (UserID): user to check Returns: bool: True if the user is an admin