Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix 500 error from /consent form
Browse files Browse the repository at this point in the history
Fixes #3731
  • Loading branch information
richvdh committed Aug 21, 2018
1 parent 3b5b64a commit f7baff6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions synapse/rest/consent/consent_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _async_render_POST(self, request):
"""
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)

Expand Down Expand Up @@ -210,9 +210,18 @@ def _render_template(self, request, template_name, **template_args):
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()

Expand Down

0 comments on commit f7baff6

Please sign in to comment.