mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
Use bcrypt for login form. Add tests to check that salts and hashes are random, and check handling of invalid passwords or salts.
This commit is contained in:
1 parent
8ba1d318ec
commit
4a9177a257
2 files changed
+73
-2
No files matched your search
@@ -7,7 +7,8 @@
|
||||
# on 1 February 2011.
|
||||
|
||||
import cherrypy
|
||||
import urllib, hashlib
|
||||
import urllib
|
||||
from passlib.hash import bcrypt
|
||||
import cfg
|
||||
import random
|
||||
import time
|
||||
@@ -31,7 +32,7 @@ def check_credentials(username, passphrase):
|
||||
u = None
|
||||
# hash the password whether the user exists, to foil timing
|
||||
# side-channel attacks
|
||||
pass_hash = hashlib.md5(passphrase).hexdigest()
|
||||
pass_hash = bcrypt.encrypt(passphrase, salt=u['salt'])
|
||||
|
||||
if u is None or u['passphrase'] != pass_hash:
|
||||
error = "Bad user-name or password."
|
||||
|
||||
Reference in new issue
Block a user