diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2018-08-22 09:15:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-22 09:15:06 +0100 |
commit | d7585a4c83e43b7a376308c85667c47984e0490b (patch) | |
tree | 810a227a89e48c91e0bc9a992f20161dc3cf97a4 /synapse | |
parent | changelog (diff) | |
parent | changelog (diff) | |
download | synapse-d7585a4c83e43b7a376308c85667c47984e0490b.tar.xz |
Merge pull request #3732 from matrix-org/rav/fix_gdpr_consent
Fix 500 error from /consent form
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/rest/consent/consent_resource.py | 15 |
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() |