summary refs log tree commit diff
path: root/synapse/api
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-09-29 13:35:15 +0100
committerErik Johnston <erik@matrix.org>2014-09-29 13:35:15 +0100
commitf7d80930f21190355733da9ba7ab5068ce0702a8 (patch)
treecf66b7e28cfa49006c8e8ddae610f8371d2f7744 /synapse/api
parentTrack the IP users connect with. Add an admin column to users table. (diff)
downloadsynapse-f7d80930f21190355733da9ba7ab5068ce0702a8.tar.xz
SYN-48: Track User-Agents as well as IPs for client devices.
Diffstat (limited to 'synapse/api')
-rw-r--r--synapse/api/auth.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/synapse/api/auth.py b/synapse/api/auth.py
index 6f8146ec3a..739f77afd4 100644
--- a/synapse/api/auth.py
+++ b/synapse/api/auth.py
@@ -223,8 +223,17 @@ class Auth(object):
             user = yield self.get_user_by_token(access_token)
 
             ip_addr = self.hs.get_ip_from_request(request)
+            user_agent = request.requestHeaders.getRawHeaders(
+                "User-Agent",
+                default=[""]
+            )[0]
             if user and access_token and ip_addr:
-                self.store.insert_client_ip(user, access_token, ip_addr)
+                self.store.insert_client_ip(
+                    user,
+                    access_token,
+                    ip_addr,
+                    user_agent
+                )
 
             defer.returnValue(user)
         except KeyError: