summary refs log tree commit diff
path: root/synapse/rest
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-08-22 09:15:44 +0100
committerRichard van der Hoff <richard@matrix.org>2018-08-22 09:15:44 +0100
commit0d568ff4035993afd8141c4076093c7e409741cd (patch)
treedc1e5bef5d0b0ab85fad4527cc98a968e16f3476 /synapse/rest
parentSplit the state_group_cache in two (#3726) (diff)
parentMerge pull request #3732 from matrix-org/rav/fix_gdpr_consent (diff)
downloadsynapse-0d568ff4035993afd8141c4076093c7e409741cd.tar.xz
Merge remote-tracking branch 'origin/release-v0.33.3' into develop
Diffstat (limited to 'synapse/rest')
-rw-r--r--synapse/rest/consent/consent_resource.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/synapse/rest/consent/consent_resource.py b/synapse/rest/consent/consent_resource.py
index 147ff7d79b..7362e1858d 100644
--- a/synapse/rest/consent/consent_resource.py
+++ b/synapse/rest/consent/consent_resource.py
@@ -140,7 +140,7 @@ class ConsentResource(Resource):
         version = parse_string(request, "v",
                                default=self._default_consent_version)
         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)
 
@@ -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()