diff options
| author | Eli Collins <elic@assurancetechnologies.com> | 2016-11-20 14:36:22 -0500 |
|---|---|---|
| committer | Eli Collins <elic@assurancetechnologies.com> | 2016-11-20 14:36:22 -0500 |
| commit | 269d54693a3af5a68e2169dfa5f98d007ed8aada (patch) | |
| tree | 2f8509d53a37744bebabf5ebfd1691b0e361fa12 /passlib/apache.py | |
| parent | 0e7ea6d5dd3b7c334b4a96a2b411470bcfa064ce (diff) | |
| download | passlib-269d54693a3af5a68e2169dfa5f98d007ed8aada.tar.gz | |
bugfix: passlib.apache: catch missing bcrypt backend, issue warning, use next best choice.
Diffstat (limited to 'passlib/apache.py')
| -rw-r--r-- | passlib/apache.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/passlib/apache.py b/passlib/apache.py index 64bac6a..ea17e5e 100644 --- a/passlib/apache.py +++ b/passlib/apache.py @@ -10,7 +10,7 @@ import os from warnings import warn # site # pkg -from passlib import registry +from passlib import exc, registry from passlib.context import CryptContext from passlib.exc import ExpectedStringError from passlib.hash import htdigest @@ -436,17 +436,25 @@ def _init_default_schemes(): host_best = name break + # check if we have a bcrypt backend -- otherwise issue warning + # XXX: would like to not spam this unless the user *requests* apache 24 + bcrypt = "bcrypt" if registry.has_backend("bcrypt") else None + if not bcrypt: + warn("HtpasswdFile: no bcrypt backends available, " + "using fallback default scheme for apache 2.4", + exc.PasslibSecurityWarning) + defaults = dict( # strongest hash builtin to specific apache version - portable_apache_24="bcrypt", + portable_apache_24=bcrypt or "apr_md5_crypt", portable_apache_22="apr_md5_crypt", # strongest hash across current host & specific apache version - host_apache_24="bcrypt", + host_apache_24=bcrypt or host_best or "apr_md5_crypt", host_apache_22=host_best or "apr_md5_crypt", # strongest hash on a linux host - linux_apache_24="bcrypt", + linux_apache_24=bcrypt or "sha256_crypt", linux_apache_22="sha256_crypt", ) |
