diff options
Diffstat (limited to 'passlib/apps.py')
-rw-r--r-- | passlib/apps.py | 85 |
1 files changed, 42 insertions, 43 deletions
diff --git a/passlib/apps.py b/passlib/apps.py index f740c90..0afb73a 100644 --- a/passlib/apps.py +++ b/passlib/apps.py @@ -1,17 +1,16 @@ """passlib.apps""" -#========================================================= -#imports -#========================================================= -#core +#============================================================================= +# imports +#============================================================================= +# core import logging; log = logging.getLogger(__name__) from itertools import chain -#site -#libs +# site +# pkg from passlib import hash from passlib.context import LazyCryptContext from passlib.utils import sys_bits -#pkg -#local +# local __all__ = [ 'custom_app_context', 'django_context', @@ -22,9 +21,9 @@ __all__ = [ 'postgres_context', ] -#========================================================= +#============================================================================= # master containing all identifiable hashes -#========================================================= +#============================================================================= def _load_master_config(): from passlib.registry import list_crypt_handlers @@ -66,29 +65,29 @@ def _load_master_config(): return dict(schemes=schemes, default="sha256_crypt") master_context = LazyCryptContext(onload=_load_master_config) -#========================================================= -#for quickly bootstrapping new custom applications -#========================================================= +#============================================================================= +# for quickly bootstrapping new custom applications +#============================================================================= custom_app_context = LazyCryptContext( - #choose some reasonbly strong schemes + # choose some reasonbly strong schemes schemes=["sha512_crypt", "sha256_crypt"], - #set some useful global options + # set some useful global options default="sha256_crypt" if sys_bits < 64 else "sha512_crypt", all__vary_rounds = 0.1, - #set a good starting point for rounds selection + # set a good starting point for rounds selection sha512_crypt__min_rounds = 60000, sha256_crypt__min_rounds = 80000, - #if the admin user category is selected, make a much stronger hash, + # if the admin user category is selected, make a much stronger hash, admin__sha512_crypt__min_rounds = 120000, admin__sha256_crypt__min_rounds = 160000, ) -#========================================================= -#django -#========================================================= +#============================================================================= +# django +#============================================================================= _django10_schemes = [ "django_salted_sha1", "django_salted_md5", "django_des_crypt", "hex_md5", "django_disabled", @@ -109,17 +108,17 @@ django14_context = LazyCryptContext( # this will always point to latest version django_context = django14_context -#========================================================= -#ldap -#========================================================= +#============================================================================= +# ldap +#============================================================================= std_ldap_schemes = ["ldap_salted_sha1", "ldap_salted_md5", "ldap_sha1", "ldap_md5", "ldap_plaintext" ] -#create context with all std ldap schemes EXCEPT crypt +# create context with all std ldap schemes EXCEPT crypt ldap_nocrypt_context = LazyCryptContext(std_ldap_schemes) -#create context with all possible std ldap + ldap crypt schemes +# create context with all possible std ldap + ldap crypt schemes def _iter_ldap_crypt_schemes(): from passlib.utils import unix_crypt_schemes return ('ldap_' + name for name in unix_crypt_schemes) @@ -129,28 +128,28 @@ def _iter_ldap_schemes(): return chain(std_ldap_schemes, _iter_ldap_crypt_schemes()) ldap_context = LazyCryptContext(_iter_ldap_schemes()) -###create context with all std ldap schemes + crypt schemes for localhost +### create context with all std ldap schemes + crypt schemes for localhost ##def _iter_host_ldap_schemes(): ## "helper which iterates over supported std ldap schemes" ## from passlib.handlers.ldap_digests import get_host_ldap_crypt_schemes ## return chain(std_ldap_schemes, get_host_ldap_crypt_schemes()) ##ldap_host_context = LazyCryptContext(_iter_host_ldap_schemes()) -#========================================================= -#mysql -#========================================================= +#============================================================================= +# mysql +#============================================================================= mysql3_context = LazyCryptContext(["mysql323"]) mysql4_context = LazyCryptContext(["mysql41", "mysql323"], deprecated="mysql323") -mysql_context = mysql4_context #tracks latest mysql version supported +mysql_context = mysql4_context # tracks latest mysql version supported -#========================================================= -#postgres -#========================================================= +#============================================================================= +# postgres +#============================================================================= postgres_context = LazyCryptContext(["postgres_md5"]) -#========================================================= -#phpass & variants -#========================================================= +#============================================================================= +# phpass & variants +#============================================================================= def _create_phpass_policy(**kwds): "helper to choose default alg based on bcrypt availability" kwds['default'] = 'bcrypt' if hash.bcrypt.has_backend() else 'phpass' @@ -163,16 +162,16 @@ phpass_context = LazyCryptContext( phpbb3_context = LazyCryptContext(["phpass"], phpass__ident="H") -#TODO: support the drupal phpass variants (see phpass homepage) +# TODO: support the drupal phpass variants (see phpass homepage) -#========================================================= -#roundup -#========================================================= +#============================================================================= +# roundup +#============================================================================= _std_roundup_schemes = [ "ldap_hex_sha1", "ldap_hex_md5", "ldap_des_crypt", "roundup_plaintext" ] roundup10_context = LazyCryptContext(_std_roundup_schemes) -#NOTE: 'roundup15' really applies to roundup 1.4.17+ +# NOTE: 'roundup15' really applies to roundup 1.4.17+ roundup_context = roundup15_context = LazyCryptContext( schemes=_std_roundup_schemes + [ "ldap_pbkdf2_sha1" ], deprecated=_std_roundup_schemes, @@ -180,6 +179,6 @@ roundup_context = roundup15_context = LazyCryptContext( ldap_pbkdf2_sha1__default_rounds = 10000, ) -#========================================================= +#============================================================================= # eof -#========================================================= +#============================================================================= |