diff options
author | Eli Collins <elic@assurancetechnologies.com> | 2019-11-11 13:43:29 -0500 |
---|---|---|
committer | Eli Collins <elic@assurancetechnologies.com> | 2019-11-11 13:43:29 -0500 |
commit | 190e4a35eb29619f52dd17fec66e5638dc0b2173 (patch) | |
tree | a411f75fb62dbe067e00e4edc5b330678617ba31 /passlib/apache.py | |
parent | e13c7c25b7145b5ef3fa0e7a424f46ab02a106c4 (diff) | |
download | passlib-190e4a35eb29619f52dd17fec66e5638dc0b2173.tar.gz |
passlib.apache: adjust default context to use "2y" bcrypt hashes instead of "2b"
(fixes issue 95).
also added UT which checks behavior against locally-installed 'htpasswd' tool
(if available).
Diffstat (limited to 'passlib/apache.py')
-rw-r--r-- | passlib/apache.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/passlib/apache.py b/passlib/apache.py index 04a64d0..35f72e5 100644 --- a/passlib/apache.py +++ b/passlib/apache.py @@ -465,6 +465,7 @@ def _init_default_schemes(): # set latest-apache version aliases # XXX: could check for apache install, and pick correct host 22/24 default? + # could reuse _detect_htpasswd() helper in UTs defaults.update( portable=defaults['portable_apache_24'], host=defaults['host_apache_24'], @@ -507,8 +508,16 @@ def _init_htpasswd_context(): preferred = schemes[:3] + ["apr_md5_crypt"] + schemes schemes = sorted(set(schemes), key=preferred.index) - # NOTE: default will change to "portable" in passlib 2.0 - return CryptContext(schemes, default=htpasswd_defaults['portable_apache_22']) + # create context object + return CryptContext( + schemes=schemes, + + # NOTE: default will change to "portable" in passlib 2.0 + default=htpasswd_defaults['portable_apache_22'], + + # NOTE: bcrypt "2y" is required, "2b" isn't recognized by libapr (issue 95) + bcrypt__ident="2y", + ) #: CryptContext configured to match htpasswd htpasswd_context = _init_htpasswd_context() |