diff options
author | Richard van der Hoff <richard@matrix.org> | 2016-11-28 09:55:21 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2016-11-29 16:49:41 +0000 |
commit | 1c4f05db41eab20f8be4ac2dac0f7e86b0b7e1fd (patch) | |
tree | 1aa5d1b54239c730c32cab8d05abf405cd6e2ff9 /synapse/handlers/auth.py | |
parent | Merge pull request #1655 from matrix-org/rav/remove_redundant_macaroon_checks (diff) | |
download | synapse-1c4f05db41eab20f8be4ac2dac0f7e86b0b7e1fd.tar.xz |
Stop putting a time caveat on access tokens
The 'time' caveat on the access tokens was something of a lie, since we weren't enforcing it; more pertinently its presence stops us ever adding useful time caveats. Let's move in the right direction by not lying in our caveats.
Diffstat (limited to 'synapse/handlers/auth.py')
-rw-r--r-- | synapse/handlers/auth.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py index a2866af431..20aaec36a4 100644 --- a/synapse/handlers/auth.py +++ b/synapse/handlers/auth.py @@ -538,14 +538,15 @@ class AuthHandler(BaseHandler): device_id) defer.returnValue(refresh_token) - def generate_access_token(self, user_id, extra_caveats=None, - duration_in_ms=(60 * 60 * 1000)): + def generate_access_token(self, user_id, extra_caveats=None): 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 + duration_in_ms - macaroon.add_first_party_caveat("time < %d" % (expiry,)) + # Include a nonce, to make sure that each login gets a different + # access token. + macaroon.add_first_party_caveat("nonce = %s" % ( + stringutils.random_string_with_symbols(16), + )) for caveat in extra_caveats: macaroon.add_first_party_caveat(caveat) return macaroon.serialize() |