-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImproperlyConfigured: hasher not found: django_sha2.hashers.bcrypt2012_06_01 #14
Comments
@tallowen wrote some code to dynamically generate hashers for HMAC/Bcrypt, there might be something broken there. |
Give me a day - i'll look into this tomorrow On Wed, Jun 6, 2012 at 3:16 PM, Fred Wenzel <
Owen Coutts Email: [email protected] |
fwiw I only saw this when upgrading an old app to the new Playdoh. I did not see this error when configuring the latest Playdoh out of the box. |
Hmm. For some reason the password hasher isn't being created. Its created dynamically at import time - it creates one per hmac_key in the settings. This probably means that django_sha2 isn't seeing the hmac_keys properly but I'm not sure why that would be the case. |
To produce:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "***/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "***/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "***/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "***/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "***/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "***/lib/python2.7/site-packages/south/management/commands/syncdb.py", line 90, in handle_noargs
syncdb.Command().execute(**options)
File "***/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "***/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "***/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 110, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "***/lib/python2.7/site-packages/django/core/management/sql.py", line 189, in emit_post_sync_signal
interactive=interactive, db=db)
File "***/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "***/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 73, in create_superuser
call_command("createsuperuser", interactive=True, database=db)
File "***/lib/python2.7/site-packages/django/core/management/__init__.py", line 150, in call_command
return klass.execute(*args, **defaults)
File "***/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "***/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 124, in handle
User.objects.db_manager(database).create_superuser(username, email, password)
File "***/lib/python2.7/site-packages/django/contrib/auth/models.py", line 164, in create_superuser
u = self.create_user(username, email, password)
File "***/lib/python2.7/site-packages/django/contrib/auth/models.py", line 159, in create_user
user.set_password(password)
File "***/lib/python2.7/site-packages/django/contrib/auth/models.py", line 294, in set_password
self.password = make_password(raw_password)
File "***/lib/python2.7/site-packages/django/contrib/auth/hashers.py", line 62, in make_password
hasher = get_hasher(hasher)
File "***/lib/python2.7/site-packages/django/contrib/auth/hashers.py", line 107, in get_hasher
load_hashers()
File "***/lib/python2.7/site-packages/django/contrib/auth/hashers.py", line 84, in load_hashers
raise ImproperlyConfigured("hasher not found: %s" % backend)
django.core.exceptions.ImproperlyConfigured: hasher not found: django_sha2.hashers.bcrypt2011_01_01 |
Looks like this error can be fixed by merge this change mozilla/playdoh@abafbf0 into older settings/local.py |
if you put that in settings/local.py then you've disabled the HMAC key (since it's commented out). I also got it working that way but for an app I knew I didn't need bcrypt for since it didn't work with users. |
Did you guys narrow this down yet? Looks like the dynamic generation of hashers is not run, perhaps? |
If you look at # django.contrib.auth.hashers
...
try:
mod_path, cls_name = backend.rsplit('.', 1)
mod = importlib.import_module(mod_path)
hasher_cls = getattr(mod, cls_name)
except (AttributeError, ImportError, ValueError):
raise ImproperlyConfigured("hasher not found: %s" % backend)
... The key here is that it's catching # django_sha2.hashers
import base64
import hmac
import hashlib
import logging
import bcrypt
from django.conf import settings
from django.contrib.auth.hashers import (BCryptPasswordHasher,
BasePasswordHasher, mask_hash)
from django.utils.crypto import constant_time_compare
from django.utils.encoding import smart_str
from django.utils.datastructures import SortedDict
... The odd one out is bcrypt, so my guess would be that this error is just occurring because |
Catching any and all import errors here is confusing |
Everytime I hit this I have to google for this issue to remember how to fix it :( Dear future self, in summary, here's what to check:
|
fwiw, I hit this error when |
This error occurred for me with an empty and a populated
So which package is it that needs to have this dependency added to it's dependency list? Is this a Django issue or a Playdoh issue? (or something else) |
Do you know why I'd be getting this error?
I'm using the latest Playdoh and have this is my local settings per instructions from django-sha2:
If I comment out the HMAC keys I no longer get the hasher not found error.
The text was updated successfully, but these errors were encountered: