summaryrefslogtreecommitdiff
path: root/passlib/ext
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2012-04-11 17:49:09 -0400
committerEli Collins <elic@assurancetechnologies.com>2012-04-11 17:49:09 -0400
commit5bd6deb8144cb24caa51e82c7682f706ecc09a6c (patch)
tree0eca5ec7a8a145cb3e166a9a75b95b393e9d417d /passlib/ext
parent157d4806512b2586c1a0fd5ee57e8c167e506f3e (diff)
downloadpasslib-5bd6deb8144cb24caa51e82c7682f706ecc09a6c.tar.gz
clarify behavior for secret=None and hash=None
* passing a non-string secret or non-string hash to any CryptContext or handler method will now reliably result in a TypeError. previously, passing hash=None to many handler identify() and verify() methods would return False, while others would raise a TypeError. other handler methods would alternately throw ValueError or TypeError when passed a value that wasn't unicode or bytes. the various CryptContext methods also behaved inconsistently, depending on the behavior of the underlying handler. all of these behaviors are gone, they should all raise the same TypeError. * redid many of the from_string() methods to verify the hash type. * moved secret type & size validation to GenericHandler's encrypt/genhash/verify methods. this cheaply made the secret validation global to all hashes, and lets _calc_digest() implementations trust that the secret is valid. * updated the CryptContext and handler unittests to verify the above behavior is adhered to.
Diffstat (limited to 'passlib/ext')
-rw-r--r--passlib/ext/django/models.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/passlib/ext/django/models.py b/passlib/ext/django/models.py
index 2b3dd16..edc334a 100644
--- a/passlib/ext/django/models.py
+++ b/passlib/ext/django/models.py
@@ -15,7 +15,7 @@ from django.conf import settings
#pkg
from passlib.context import CryptContext, CryptPolicy
from passlib.utils import is_crypt_context
-from passlib.utils.compat import bytes, sb_types, unicode
+from passlib.utils.compat import bytes, unicode, base_string_types
from passlib.ext.django.utils import DEFAULT_CTX, get_category, \
set_django_password_context
@@ -34,7 +34,7 @@ def patch():
return
if ctx == "passlib-default":
ctx = DEFAULT_CTX
- if isinstance(ctx, str):
+ if isinstance(ctx, base_string_types):
ctx = CryptContext(policy=CryptPolicy.from_string(ctx))
if not is_crypt_context(ctx):
raise TypeError("django settings.PASSLIB_CONTEXT must be CryptContext "