diff options
-rw-r--r-- | mediagoblin/auth/__init__.py | 5 | ||||
-rw-r--r-- | mediagoblin/plugins/basic_auth/__init__.py | 5 | ||||
-rw-r--r-- | mediagoblin/tests/test_edit.py | 6 |
3 files changed, 13 insertions, 3 deletions
diff --git a/mediagoblin/auth/__init__.py b/mediagoblin/auth/__init__.py index 3966ecd3..53182eaa 100644 --- a/mediagoblin/auth/__init__.py +++ b/mediagoblin/auth/__init__.py @@ -53,5 +53,10 @@ def gen_password_hash(raw_pass, extra_salt=None): return hook_handle("auth_gen_password_hash", raw_pass, extra_salt) +def check_password(raw_pass, stored_hash, extra_salt=None): + return hook_handle("auth_check_password", + raw_pass, stored_hash, extra_salt) + + def fake_login_attempt(): return hook_handle("auth_fake_login_attempt") diff --git a/mediagoblin/plugins/basic_auth/__init__.py b/mediagoblin/plugins/basic_auth/__init__.py index d0545627..2d6f7dbd 100644 --- a/mediagoblin/plugins/basic_auth/__init__.py +++ b/mediagoblin/plugins/basic_auth/__init__.py @@ -71,6 +71,10 @@ def gen_password_hash(raw_pass, extra_salt): return auth_lib.bcrypt_gen_password_hash(raw_pass, extra_salt) +def check_password(raw_pass, stored_hash, extra_salt): + return auth_lib.bcrypt_check_password(raw_pass, stored_hash, extra_salt) + + def auth(): return True @@ -94,6 +98,7 @@ hooks = { 'auth_get_login_form': get_login_form, 'auth_get_registration_form': get_registration_form, 'auth_gen_password_hash': gen_password_hash, + 'auth_check_password': check_password, 'auth_fake_login_attempt': auth_lib.fake_login_attempt, 'template_global_context': append_to_global_context, ('mediagoblin.plugins.openid.register', diff --git a/mediagoblin/tests/test_edit.py b/mediagoblin/tests/test_edit.py index ccdf9c29..b6ec7a29 100644 --- a/mediagoblin/tests/test_edit.py +++ b/mediagoblin/tests/test_edit.py @@ -21,7 +21,7 @@ from mediagoblin import mg_globals from mediagoblin.db.models import User from mediagoblin.tests.tools import fixture_add_user from mediagoblin.tools import template -from mediagoblin.plugins.basic_auth.lib import bcrypt_check_password +from mediagoblin import auth class TestUserEdit(object): @@ -75,7 +75,7 @@ class TestUserEdit(object): # test_user has to be fetched again in order to have the current values test_user = User.query.filter_by(username=u'chris').first() - assert bcrypt_check_password('123456', test_user.pw_hash) + assert auth.check_password('123456', test_user.pw_hash) # Update current user passwd self.user_password = '123456' @@ -89,7 +89,7 @@ class TestUserEdit(object): }) test_user = User.query.filter_by(username=u'chris').first() - assert not bcrypt_check_password('098765', test_user.pw_hash) + assert not auth.check_password('098765', test_user.pw_hash) def test_change_bio_url(self, test_app): |