Python django.conf.settings.PASSWORD_HASHERS Examples

The following are 19 code examples of django.conf.settings.PASSWORD_HASHERS(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.conf.settings , or try the search function .
Example #1
Source File: hashers.py    From GTDWeb with GNU General Public License v2.0 6 votes vote down vote up
def get_hasher(algorithm='default'):
    """
    Returns an instance of a loaded password hasher.

    If algorithm is 'default', the default hasher will be returned.
    This function will also lazy import hashers specified in your
    settings file if needed.
    """
    if hasattr(algorithm, 'algorithm'):
        return algorithm

    elif algorithm == 'default':
        return get_hashers()[0]

    else:
        hashers = get_hashers_by_algorithm()
        try:
            return hashers[algorithm]
        except KeyError:
            raise ValueError("Unknown password hashing algorithm '%s'. "
                             "Did you specify it in the PASSWORD_HASHERS "
                             "setting?" % algorithm) 
Example #2
Source File: views.py    From govready-q with GNU General Public License v3.0 6 votes vote down vote up
def shared_static_pages(request, page):
    from django.utils.module_loading import import_string
    from django.contrib.humanize.templatetags.humanize import intcomma
    password_hasher = import_string(settings.PASSWORD_HASHERS[0])()
    password_hash_method = password_hasher.algorithm.upper().replace("_", " ") \
        + " (" + intcomma(password_hasher.iterations) + " iterations)"

    return render(request,
        page + ".html", {
        "base_template": "base.html",
        "SITE_ROOT_URL": request.build_absolute_uri("/"),
        "password_hash_method": password_hash_method,
        # "project_form": ProjectForm(request.user),
        "project_form": None,
    })

# SINGLE SIGN ON 
Example #3
Source File: hashers.py    From bioforum with MIT License 6 votes vote down vote up
def get_hasher(algorithm='default'):
    """
    Return an instance of a loaded password hasher.

    If algorithm is 'default', return the default hasher. Lazily import hashers
    specified in the project's settings file if needed.
    """
    if hasattr(algorithm, 'algorithm'):
        return algorithm

    elif algorithm == 'default':
        return get_hashers()[0]

    else:
        hashers = get_hashers_by_algorithm()
        try:
            return hashers[algorithm]
        except KeyError:
            raise ValueError("Unknown password hashing algorithm '%s'. "
                             "Did you specify it in the PASSWORD_HASHERS "
                             "setting?" % algorithm) 
Example #4
Source File: hashers.py    From python2017 with MIT License 6 votes vote down vote up
def get_hasher(algorithm='default'):
    """
    Returns an instance of a loaded password hasher.

    If algorithm is 'default', the default hasher will be returned.
    This function will also lazy import hashers specified in your
    settings file if needed.
    """
    if hasattr(algorithm, 'algorithm'):
        return algorithm

    elif algorithm == 'default':
        return get_hashers()[0]

    else:
        hashers = get_hashers_by_algorithm()
        try:
            return hashers[algorithm]
        except KeyError:
            raise ValueError("Unknown password hashing algorithm '%s'. "
                             "Did you specify it in the PASSWORD_HASHERS "
                             "setting?" % algorithm) 
Example #5
Source File: hashers.py    From Hands-On-Application-Development-with-PyCharm with MIT License 6 votes vote down vote up
def get_hasher(algorithm='default'):
    """
    Return an instance of a loaded password hasher.

    If algorithm is 'default', return the default hasher. Lazily import hashers
    specified in the project's settings file if needed.
    """
    if hasattr(algorithm, 'algorithm'):
        return algorithm

    elif algorithm == 'default':
        return get_hashers()[0]

    else:
        hashers = get_hashers_by_algorithm()
        try:
            return hashers[algorithm]
        except KeyError:
            raise ValueError("Unknown password hashing algorithm '%s'. "
                             "Did you specify it in the PASSWORD_HASHERS "
                             "setting?" % algorithm) 
Example #6
Source File: hashers.py    From openhgsenti with Apache License 2.0 6 votes vote down vote up
def get_hasher(algorithm='default'):
    """
    Returns an instance of a loaded password hasher.

    If algorithm is 'default', the default hasher will be returned.
    This function will also lazy import hashers specified in your
    settings file if needed.
    """
    if hasattr(algorithm, 'algorithm'):
        return algorithm

    elif algorithm == 'default':
        return get_hashers()[0]

    else:
        hashers = get_hashers_by_algorithm()
        try:
            return hashers[algorithm]
        except KeyError:
            raise ValueError("Unknown password hashing algorithm '%s'. "
                             "Did you specify it in the PASSWORD_HASHERS "
                             "setting?" % algorithm) 
Example #7
Source File: __init__.py    From healthchecks with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        # For speed:
        settings.PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",)

        # Send emails synchronously
        settings.BLOCKING_EMAILS = True

        super(CustomRunner, self).__init__(*args, **kwargs) 
Example #8
Source File: conftest.py    From openag-device-software with GNU General Public License v3.0 5 votes vote down vote up
def pytest_configure():
    settings.DEBUG = False
    # If you have any test specific settings, you can declare them here,
    # e.g.
    # settings.PASSWORD_HASHERS = (
    #     'django.contrib.auth.hashers.MD5PasswordHasher',
    # )
    django.setup()


# Give django database access to all tests.
# The alternative is to mark just the test functions that need DB access with:
#    @pytest.mark.django_db 
Example #9
Source File: conftest.py    From drf-rw-serializers with MIT License 5 votes vote down vote up
def pytest_configure():
    settings.DEBUG = False
    # If you have any test specific settings, you can declare them here,
    # e.g.
    # settings.PASSWORD_HASHERS = (
    #     'django.contrib.auth.hashers.MD5PasswordHasher',
    # )
    django.setup()
    # Note: In Django =< 1.6 you'll need to run this instead
    # settings.configure() 
Example #10
Source File: hashers.py    From python2017 with MIT License 5 votes vote down vote up
def reset_hashers(**kwargs):
    if kwargs['setting'] == 'PASSWORD_HASHERS':
        get_hashers.cache_clear()
        get_hashers_by_algorithm.cache_clear() 
Example #11
Source File: hashers.py    From python2017 with MIT License 5 votes vote down vote up
def get_hashers():
    hashers = []
    for hasher_path in settings.PASSWORD_HASHERS:
        hasher_cls = import_string(hasher_path)
        hasher = hasher_cls()
        if not getattr(hasher, 'algorithm'):
            raise ImproperlyConfigured("hasher doesn't specify an "
                                       "algorithm name: %s" % hasher_path)
        hashers.append(hasher)
    return hashers 
Example #12
Source File: hashers.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def reset_hashers(**kwargs):
    if kwargs['setting'] == 'PASSWORD_HASHERS':
        get_hashers.cache_clear()
        get_hashers_by_algorithm.cache_clear() 
Example #13
Source File: hashers.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def get_hashers():
    hashers = []
    for hasher_path in settings.PASSWORD_HASHERS:
        hasher_cls = import_string(hasher_path)
        hasher = hasher_cls()
        if not getattr(hasher, 'algorithm'):
            raise ImproperlyConfigured("hasher doesn't specify an "
                                       "algorithm name: %s" % hasher_path)
        hashers.append(hasher)
    return hashers 
Example #14
Source File: hashers.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def get_hashers():
    hashers = []
    for hasher_path in settings.PASSWORD_HASHERS:
        hasher_cls = import_string(hasher_path)
        hasher = hasher_cls()
        if not getattr(hasher, 'algorithm'):
            raise ImproperlyConfigured("hasher doesn't specify an "
                                       "algorithm name: %s" % hasher_path)
        hashers.append(hasher)
    return hashers 
Example #15
Source File: hashers.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def reset_hashers(**kwargs):
    if kwargs['setting'] == 'PASSWORD_HASHERS':
        get_hashers.cache_clear()
        get_hashers_by_algorithm.cache_clear() 
Example #16
Source File: hashers.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def get_hashers():
    hashers = []
    for hasher_path in settings.PASSWORD_HASHERS:
        hasher_cls = import_string(hasher_path)
        hasher = hasher_cls()
        if not getattr(hasher, 'algorithm'):
            raise ImproperlyConfigured("hasher doesn't specify an "
                                       "algorithm name: %s" % hasher_path)
        hashers.append(hasher)
    return hashers 
Example #17
Source File: hashers.py    From bioforum with MIT License 5 votes vote down vote up
def reset_hashers(**kwargs):
    if kwargs['setting'] == 'PASSWORD_HASHERS':
        get_hashers.cache_clear()
        get_hashers_by_algorithm.cache_clear() 
Example #18
Source File: hashers.py    From bioforum with MIT License 5 votes vote down vote up
def get_hashers():
    hashers = []
    for hasher_path in settings.PASSWORD_HASHERS:
        hasher_cls = import_string(hasher_path)
        hasher = hasher_cls()
        if not getattr(hasher, 'algorithm'):
            raise ImproperlyConfigured("hasher doesn't specify an "
                                       "algorithm name: %s" % hasher_path)
        hashers.append(hasher)
    return hashers 
Example #19
Source File: hashers.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def reset_hashers(**kwargs):
    if kwargs['setting'] == 'PASSWORD_HASHERS':
        get_hashers.cache_clear()
        get_hashers_by_algorithm.cache_clear()