mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
Simplify authentication code.
This commit is contained in:
parent
ad7f932fe8
commit
dc5139bd2d
@ -28,13 +28,11 @@ def check_credentials(username, passphrase):
|
|||||||
return error
|
return error
|
||||||
|
|
||||||
u = cfg.users[username]
|
u = cfg.users[username]
|
||||||
|
# hash the password whether the user exists, to foil timing
|
||||||
|
# side-channel attacks
|
||||||
|
pass_hash = hashlib.md5(passphrase).hexdigest()
|
||||||
|
|
||||||
if u is None:
|
if u is None or u['passphrase'] != pass_hash:
|
||||||
# hash the password whether the user exists, to foil timing
|
|
||||||
# side-channel attacks
|
|
||||||
hashlib.md5(passphrase).hexdigest()
|
|
||||||
error = "Bad user-name or password."
|
|
||||||
elif u['passphrase'] != hashlib.md5(passphrase).hexdigest():
|
|
||||||
error = "Bad user-name or password."
|
error = "Bad user-name or password."
|
||||||
else:
|
else:
|
||||||
error = None
|
error = None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user