summary refs log tree commit diff
path: root/synapse/rest/consent/consent_resource.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-08-21 22:41:41 +0100
committerRichard van der Hoff <richard@matrix.org>2018-08-21 22:47:07 +0100
commitf7baff6f7b4af039254ec16e9272b90adb58dab3 (patch)
treec2fac0c0da05c66e5f10970f5a903974dabec518 /synapse/rest/consent/consent_resource.py
parentchangelog (diff)
downloadsynapse-f7baff6f7b4af039254ec16e9272b90adb58dab3.tar.xz
Fix 500 error from /consent form
Fixes #3731
Diffstat (limited to 'synapse/rest/consent/consent_resource.py')
-rw-r--r--synapse/rest/consent/consent_resource.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/synapse/rest/consent/consent_resource.py b/synapse/rest/consent/consent_resource.py
index 147ff7d79b..52954ada12 100644
--- a/synapse/rest/consent/consent_resource.py
+++ b/synapse/rest/consent/consent_resource.py
@@ -175,7 +175,7 @@ class ConsentResource(Resource):
         """
         version = parse_string(request, "v", required=True)
         username = parse_string(request, "u", required=True)
-        userhmac = parse_string(request, "h", required=True)
+        userhmac = parse_string(request, "h", required=True, encoding=None)
 
         self._check_hash(username, userhmac)
 
@@ -210,9 +210,18 @@ class ConsentResource(Resource):
         finish_request(request)
 
     def _check_hash(self, userid, userhmac):
+        """
+        Args:
+            userid (unicode):
+            userhmac (bytes):
+
+        Raises:
+              SynapseError if the hash doesn't match
+
+        """
         want_mac = hmac.new(
             key=self._hmac_secret,
-            msg=userid,
+            msg=userid.encode('utf-8'),
             digestmod=sha256,
         ).hexdigest()