| 1 |
Admin |
| 2 |
===== |
| 3 |
|
| 4 |
The Django admin site (``django.contrib.admin``) does not use Django allauth by |
| 5 |
default. Since Django admin provides a custom login view, it does not go through |
| 6 |
the normal Django allauth workflow. |
| 7 |
|
| 8 |
.. warning:: |
| 9 |
|
| 10 |
This limitation means that Django allauth features are not applied to the |
| 11 |
Django admin site: |
| 12 |
|
| 13 |
* The admin login is not protected from being brute forced (``ACCOUNT_RATE_LIMITS``). |
| 14 |
* Two-factor authentication is not enforced. |
| 15 |
* Any other custom workflow that overrides the Django allauth adapter's |
| 16 |
login method will not be applied. |
| 17 |
|
| 18 |
An easy workaround for this is to require users to login before going to the |
| 19 |
Django admin site's login page, by adding this to urls.py (note that the following would need to be applied to |
| 20 |
every instance of ``AdminSite``): |
| 21 |
|
| 22 |
|
| 23 |
.. code-block:: python |
| 24 |
|
| 25 |
from django.contrib import admin |
| 26 |
from allauth.account.decorators import secure_admin_login |
| 27 |
|
| 28 |
admin.autodiscover() |
| 29 |
admin.site.login = secure_admin_login(admin.site.login) |