diff options
author | Erik Johnston <erik@matrix.org> | 2014-09-26 16:36:24 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-09-26 16:36:24 +0100 |
commit | 0fdf3088743b25e9fcc39b7b3b4c7f6e8332e26c (patch) | |
tree | a5433fb7afa8fb62c65f5a4395c7ed7b1f0a9af4 /synapse/api/auth.py | |
parent | Merge branch 'master' of github.com:matrix-org/synapse into develop (diff) | |
download | synapse-0fdf3088743b25e9fcc39b7b3b4c7f6e8332e26c.tar.xz |
Track the IP users connect with. Add an admin column to users table.
Diffstat (limited to 'synapse/api/auth.py')
-rw-r--r-- | synapse/api/auth.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py index 9bfd25c86e..6f8146ec3a 100644 --- a/synapse/api/auth.py +++ b/synapse/api/auth.py @@ -206,6 +206,7 @@ class Auth(object): defer.returnValue(True) + @defer.inlineCallbacks def get_user_by_req(self, request): """ Get a registered user's ID. @@ -218,7 +219,14 @@ class Auth(object): """ # Can optionally look elsewhere in the request (e.g. headers) try: - return self.get_user_by_token(request.args["access_token"][0]) + access_token = request.args["access_token"][0] + user = yield self.get_user_by_token(access_token) + + ip_addr = self.hs.get_ip_from_request(request) + if user and access_token and ip_addr: + self.store.insert_client_ip(user, access_token, ip_addr) + + defer.returnValue(user) except KeyError: raise AuthError(403, "Missing access token.") |