summary refs log tree commit diff
path: root/synapse/handlers/auth.py
diff options
context:
space:
mode:
authorNegar Fazeli <negar.fazeli@ericsson.com>2016-07-08 16:53:18 +0200
committerNegar Fazeli <negar.fazeli@ericsson.com>2016-07-13 15:00:37 +0200
commit0136a522b18a734db69171d60566f501c0ced663 (patch)
tree0828758ba08b5eba36d0442a9785ebf9341b2033 /synapse/handlers/auth.py
parentMerge pull request #914 from matrix-org/markjh/upgrade (diff)
downloadsynapse-0136a522b18a734db69171d60566f501c0ced663.tar.xz
Bug fix: expire invalid access tokens
Diffstat (limited to 'synapse/handlers/auth.py')
-rw-r--r--synapse/handlers/auth.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py
index e259213a36..5a0ed9d6b9 100644
--- a/synapse/handlers/auth.py
+++ b/synapse/handlers/auth.py
@@ -637,12 +637,13 @@ class AuthHandler(BaseHandler):
         yield self.store.add_refresh_token_to_user(user_id, refresh_token)
         defer.returnValue(refresh_token)
 
-    def generate_access_token(self, user_id, extra_caveats=None):
+    def generate_access_token(self, user_id, extra_caveats=None,
+                              duration_in_ms=(60 * 60 * 1000)):
         extra_caveats = extra_caveats or []
         macaroon = self._generate_base_macaroon(user_id)
         macaroon.add_first_party_caveat("type = access")
         now = self.hs.get_clock().time_msec()
-        expiry = now + (60 * 60 * 1000)
+        expiry = now + duration_in_ms
         macaroon.add_first_party_caveat("time < %d" % (expiry,))
         for caveat in extra_caveats:
             macaroon.add_first_party_caveat(caveat)