Attempt to validate macaroons

A couple of weird caveats:
 * If we can't validate your macaroon, we fall back to checking that
   your access token is in the DB, and ignoring the failure
 * Even if we can validate your macaroon, we still have to hit the DB to
   get the access token ID, which we pretend is a device ID all over the
   codebase.

This mostly adds the interesting code, and points out the two pieces we
need to delete (and necessary conditions) in order to fix the above
caveats.
This commit is contained in:
Daniel Wagner-Hall 2015-08-26 13:22:23 +01:00
parent a2355fae7e
commit 6a4b650d8a
7 changed files with 257 additions and 36 deletions

View file

@ -63,11 +63,11 @@ class RoomTypingTestCase(RestTestCase):
def _get_user_by_access_token(token=None):
return {
"user": UserID.from_string(self.auth_user_id),
"user_id": UserID.from_string(self.auth_user_id),
"token_id": 1,
}
hs.get_v1auth().get_user_by_access_token = _get_user_by_access_token
hs.get_v1auth()._get_user_by_access_token = _get_user_by_access_token
def _insert_client_ip(*args, **kwargs):
return defer.succeed(None)