mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-23 01:55:53 +03:00
parent
3b5b64ac99
commit
f7baff6f7b
1 changed files with 11 additions and 2 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue