summaryrefslogtreecommitdiff
path: root/passlib/ext
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2016-02-09 12:07:46 -0500
committerEli Collins <elic@assurancetechnologies.com>2016-02-09 12:07:46 -0500
commitfe6270ef83e447a9bf1c2fccb8e72342d12b783c (patch)
treefb11fcfb4d66b53ba7562683b528a0283d974629 /passlib/ext
parent79441fd7909b3d158e6432a28791c6689e00a43a (diff)
downloadpasslib-fe6270ef83e447a9bf1c2fccb8e72342d12b783c.tar.gz
passlib.ext.django: dropped support for django 1.6-1.7, per passlib 1.6.6 announcement
motivation is that django hashers framework has matured greatly as of django 1.8, and dropping all prior versions not only eases support burden, but opens up opportunity for integration via less invasive method in a future passlib release, using django 1.8 as a common base.
Diffstat (limited to 'passlib/ext')
-rw-r--r--passlib/ext/django/models.py27
-rw-r--r--passlib/ext/django/utils.py17
2 files changed, 17 insertions, 27 deletions
diff --git a/passlib/ext/django/models.py b/passlib/ext/django/models.py
index e60a9cf..0349012 100644
--- a/passlib/ext/django/models.py
+++ b/passlib/ext/django/models.py
@@ -68,12 +68,13 @@ def _apply_patch():
# import some helpers from hashers module
#
from django.contrib.auth.hashers import is_password_usable
+ from django.utils import lru_cache
+ from passlib.utils.compat import lmap
#
# patch ``User.set_password() & ``User.check_password()`` to use
# context & get_category (would just leave these as wrappers for hashers
- # module under django 1.4, but then we couldn't pass User object into
- # get_category very easily)
+ # module, but then we couldn't pass User object into get_category very easily)
#
@_manager.monkeypatch(USER_PATH)
def set_password(user, password):
@@ -155,20 +156,16 @@ def _apply_patch():
kwds['salt'] = salt
return password_context.encrypt(password, **kwds)
- if VERSION >= (1, 8):
- from django.utils import lru_cache
- from passlib.utils.compat import lmap
-
- @_manager.monkeypatch(HASHERS_PATH)
- @lru_cache.lru_cache()
- def get_hashers():
- """passlib replacement for get_hashers()"""
- return lmap(get_passlib_hasher, password_context.schemes(resolve=True))
+ @_manager.monkeypatch(HASHERS_PATH)
+ @lru_cache.lru_cache()
+ def get_hashers():
+ """passlib replacement for get_hashers()"""
+ return lmap(get_passlib_hasher, password_context.schemes(resolve=True))
- # NOTE: leaving get_hashers_by_algorithm() unpatched, since it just
- # proxies get_hashers(). but we do want to wipe it's cache...
- from django.contrib.auth.hashers import reset_hashers
- reset_hashers(setting="PASSWORD_HASHERS")
+ # NOTE: leaving get_hashers_by_algorithm() unpatched, since it just
+ # proxies get_hashers(). but we do want to wipe it's cache...
+ from django.contrib.auth.hashers import reset_hashers
+ reset_hashers(setting="PASSWORD_HASHERS")
@_manager.monkeypatch(HASHERS_PATH)
@_manager.monkeypatch(FORMS_PATH)
diff --git a/passlib/ext/django/utils.py b/passlib/ext/django/utils.py
index 511427c..07a11db 100644
--- a/passlib/ext/django/utils.py
+++ b/passlib/ext/django/utils.py
@@ -29,7 +29,7 @@ __all__ = [
]
#: minimum version supported by passlib.ext.django
-MIN_DJANGO_VERSION = (1, 6)
+MIN_DJANGO_VERSION = (1, 8)
#=============================================================================
# default policies
@@ -318,7 +318,7 @@ def get_passlib_hasher(handler, algorithm=None, native_only=False):
This takes in the name of a passlib hash (or the handler object itself),
and returns a wrapper instance which should be compatible with
- Django 1.4's Hashers framework.
+ Django's Hashers framework.
If the named hash corresponds to one of Django's builtin hashers,
an instance of the real hasher class will be returned.
@@ -358,17 +358,10 @@ def _get_hasher(algorithm):
# we haven't patched django, so just import directly
from django.contrib.auth.hashers import get_hasher
return get_hasher(algorithm)
- elif DJANGO_VERSION < (1,8):
- # django < 1.8
- # we've patched django, so have to use patch manager to retrieve
- # original get_hasher() function...
- get_hasher = module._manager.getorig("django.contrib.auth.hashers:get_hasher")
- return get_hasher(algorithm)
else:
- # django >= 1.8
- # we've patched django, but patched at get_hashers() level...
- # calling original get_hasher() would only land us back here via patched get_hashers().
- # as non-ideal workaround, have to use original get_hashers()
+ # We've patched django's get_hashers(), so calling django's get_hasher()
+ # or get_hashers_by_algorithm() would only land us back here via patched get_hashers().
+ # As non-ideal workaround, have to use original get_hashers()...
get_hashers = module._manager.getorig("django.contrib.auth.hashers:get_hashers")
for hasher in get_hashers():
if hasher.algorithm == algorithm: