Use default values for encrypt_password and verify_password

This commit is contained in:
Matt Wright
2012-08-20 17:44:20 -04:00
parent 3a07970216
commit fa4668aa3f
5 changed files with 12 additions and 14 deletions
+1 -3
View File
@@ -378,9 +378,7 @@ class AuthenticationProvider(object):
raise exceptions.ConfirmationError('Email requires confirmation.', user)
# compare passwords
if verify_password(password, user.password,
salt=_security.password_salt,
use_hmac=_security.password_hmac):
if verify_password(password, user.password):
return user
# bad match
+1 -3
View File
@@ -95,9 +95,7 @@ class UserDatastore(object):
pw = kwargs['password']
if not pwd_context.identify(pw):
pwd_hash = utils.encrypt_password(pw,
salt=_security.password_salt,
use_hmac=_security.password_hmac)
pwd_hash = utils.encrypt_password(pw)
kwargs['password'] = pwd_hash
return kwargs
+1 -3
View File
@@ -69,9 +69,7 @@ def _check_http_auth():
try:
user = _security.datastore.find_user(email=auth.username)
if utils.verify_password(auth.password, user.password,
salt=_security.password_salt,
use_hmac=_security.password_hmac):
if utils.verify_password(auth.password, user.password):
identity_changed.send(current_app._get_current_object(),
identity=Identity(user.id))
return True
+1 -3
View File
@@ -79,9 +79,7 @@ def reset_by_token(token, password):
data = serializer.loads(token, max_age=max_age)
user = _datastore.find_user(id=data[0])
user.password = encrypt_password(password,
salt=_security.password_salt,
use_hmac=_security.password_hmac)
user.password = encrypt_password(password)
_datastore._save_model(user)
send_password_reset_notice(user)
+8 -2
View File
@@ -85,12 +85,18 @@ def get_hmac(msg, salt=None, digestmod=None):
return base64.b64encode(hmac.new(salt, msg, digestmod).digest())
def verify_password(password, password_hash, salt=None, use_hmac=False):
def verify_password(password, password_hash, salt=None, use_hmac=None):
salt = salt or _security.password_salt
if use_hmac is None:
use_hmac = _security.password_hmac
hmac_value = get_hmac(password, salt) if use_hmac else password
return _pwd_context.verify(hmac_value, password_hash)
def encrypt_password(password, salt=None, use_hmac=False):
def encrypt_password(password, salt=None, use_hmac=None):
salt = salt or _security.password_salt
if use_hmac is None:
use_hmac = _security.password_hmac
hmac_value = get_hmac(password, salt) if use_hmac else password
return _pwd_context.encrypt(hmac_value)