diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py
index 6b31f72..2eaf6c8 100644
a
|
b
|
from __future__ import unicode_literals
|
2 | 2 | from django.contrib.auth import get_user_model |
3 | 3 | from django.contrib.auth.models import Permission |
4 | 4 | |
| 5 | from time import sleep |
| 6 | from random import random |
5 | 7 | |
6 | 8 | class ModelBackend(object): |
7 | 9 | """ |
… |
… |
class ModelBackend(object):
|
10 | 12 | |
11 | 13 | def authenticate(self, username=None, password=None, **kwargs): |
12 | 14 | UserModel = get_user_model() |
| 15 | |
| 16 | user = UserModel() |
| 17 | user.set_password("if user doesn't exist we still want to be slow") |
| 18 | |
| 19 | #sleep for random amount of time to add some secret sauce |
| 20 | #to the time it takes for authentication |
| 21 | sleep( (random() + .25) % .5) |
| 22 | |
13 | 23 | if username is None: |
14 | 24 | username = kwargs.get(UserModel.USERNAME_FIELD) |
15 | 25 | try: |
… |
… |
class ModelBackend(object):
|
17 | 27 | if user.check_password(password): |
18 | 28 | return user |
19 | 29 | except UserModel.DoesNotExist: |
| 30 | user.check_password("this won't match that!") |
20 | 31 | return None |
21 | 32 | |
22 | 33 | def get_group_permissions(self, user_obj, obj=None): |