Use hmac.compare_digest to compare hashes

Co-Authored-By: Timost <Timost@users.noreply.github.com>
This commit is contained in:
Alexandre Aubin 2019-11-19 14:19:35 +01:00 committed by GitHub
parent e77e27730b
commit f1087662a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -184,7 +184,7 @@ class BaseAuthenticator(object):
to_hash = "{id}:{token}".format(id=session_id, token=session_token)
hash_ = hashlib.sha256(to_hash).hexdigest()
if hash_ != stored_hash:
if not hmac.compare_digest(hash_, stored_hash):
raise MoulinetteError('invalid_token')
else:
return