summaryrefslogtreecommitdiff
path: root/django/contrib/auth/base_user.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-07-31 20:56:33 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-08-04 09:35:24 +0200
commitd907371ef99a1e4ca6bc1660f57d81f265750984 (patch)
treec71660e797eba97a3a6a6fa48ebc3f1bfa64441b /django/contrib/auth/base_user.py
parentbce4a53670668d6fd1e34685197151c17fd1b378 (diff)
Fixed #31842 -- Added DEFAULT_HASHING_ALGORITHM transitional setting.
It's a transitional setting helpful in migrating multiple instance of the same project to Django 3.1+. Thanks Markus Holtermann for the report and review, Florian Apolloner for the implementation idea and review, and Carlton Gibson for the review.
Diffstat (limited to 'django/contrib/auth/base_user.py')
-rw-r--r--django/contrib/auth/base_user.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/django/contrib/auth/base_user.py b/django/contrib/auth/base_user.py
index bb51cfbcc9..3a4a64ee19 100644
--- a/django/contrib/auth/base_user.py
+++ b/django/contrib/auth/base_user.py
@@ -4,6 +4,7 @@ not in INSTALLED_APPS.
"""
import unicodedata
+from django.conf import settings
from django.contrib.auth import password_validation
from django.contrib.auth.hashers import (
check_password, is_password_usable, make_password,
@@ -130,7 +131,14 @@ class AbstractBaseUser(models.Model):
Return an HMAC of the password field.
"""
key_salt = "django.contrib.auth.models.AbstractBaseUser.get_session_auth_hash"
- return salted_hmac(key_salt, self.password, algorithm='sha256').hexdigest()
+ return salted_hmac(
+ key_salt,
+ self.password,
+ # RemovedInDjango40Warning: when the deprecation ends, replace
+ # with:
+ # algorithm='sha256',
+ algorithm=settings.DEFAULT_HASHING_ALGORITHM,
+ ).hexdigest()
@classmethod
def get_email_field_name(cls):