當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.PASSWORD_HASHERS屬性代碼示例

本文整理匯總了Python中django.conf.settings.PASSWORD_HASHERS屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.PASSWORD_HASHERS屬性的具體用法?Python settings.PASSWORD_HASHERS怎麽用?Python settings.PASSWORD_HASHERS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在django.conf.settings的用法示例。


在下文中一共展示了settings.PASSWORD_HASHERS屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_hasher

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import PASSWORD_HASHERS [as 別名]
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) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:24,代碼來源:hashers.py

示例2: get_hasher

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import PASSWORD_HASHERS [as 別名]
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) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:23,代碼來源:hashers.py

示例3: shared_static_pages

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import PASSWORD_HASHERS [as 別名]
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 
開發者ID:GovReady,項目名稱:govready-q,代碼行數:19,代碼來源:views.py

示例4: get_hashers

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import PASSWORD_HASHERS [as 別名]
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 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:12,代碼來源:hashers.py

示例5: reset_hashers

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import PASSWORD_HASHERS [as 別名]
def reset_hashers(**kwargs):
    if kwargs['setting'] == 'PASSWORD_HASHERS':
        get_hashers.cache_clear()
        get_hashers_by_algorithm.cache_clear() 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:6,代碼來源:hashers.py

示例6: __init__

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import PASSWORD_HASHERS [as 別名]
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) 
開發者ID:healthchecks,項目名稱:healthchecks,代碼行數:10,代碼來源:__init__.py

示例7: pytest_configure

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import PASSWORD_HASHERS [as 別名]
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() 
開發者ID:vintasoftware,項目名稱:drf-rw-serializers,代碼行數:12,代碼來源:conftest.py

示例8: pytest_configure

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import PASSWORD_HASHERS [as 別名]
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 
開發者ID:OpenAgricultureFoundation,項目名稱:openag-device-software,代碼行數:15,代碼來源:conftest.py


注:本文中的django.conf.settings.PASSWORD_HASHERS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。