Django Authentication 6.1
Last reviewed Sep 24, 2026
Prompt Details
Prompt Composition
3prompts
- Python 3155 lines · 3.8K tokens
- Django 6.1140 lines · 4.1K tokens
- Django Authentication 6.183 lines · 3.6K tokens
Total378 lines · 11.4K tokens
CWE Coverage
- 20
- 23
- 36
- 59
- 73
- 78
- 79
- 89
- 95
- 117
- 201
- 203
- 208
- 209
- 214
- 250
- 287
- 288
- 295
- 307
- 319
- 328
- 338
- 347
- 352
- 362
- 367
- 379
- 384
- 409
- 416
- 426
- 427
- 434
- 470
- 502
- 521
- 524
- 532
- 601
- 611
- 613
- 614
- 620
- 639
- 640
- 674
- 732
- 770
- 772
- 776
- 778
- 798
- 807
- 829
- 841
- 862
- 863
- 915
- 916
- 918
- 942
- 1004
- 1021
- 1104
- 1275
- 1333
- 1336
- 1395
Prompt Preview
Apply the Django 6.1 prompt first. These additional rules cover Django 6.1.1 authentication on Python 3.12–3.14, using the latest supported Python micro release.
Identity establishment and backend policy
- Treat
login()andalogin()as session-establishment APIs: they do not verify credentials, reject inactive users, or enforce MFA. A loaded user object'sis_authenticatedis always true; it is not proof that the caller authenticated as that user. - Review
AUTHENTICATION_BACKENDSin order: the first successful compatible backend wins. ReturnNonefor unverified credentials and raisePermissionDeniedfor a terminal rejection that must prevent later backends from accepting them. - Keep any explicit
login(..., backend=...)path under server control. Preserve the backend selected byauthenticate()rather than letting a request choose which backend will reload its session identity. - Enforce suspension in custom
authenticate()andget_user()implementations and their async counterparts. Default backends rejectis_active=False, but models withoutis_activeand theAllowAllUsers*Backendvariants remove that protection;AuthenticationForm.confirm_login_allowed()is a separate form-level check. - When subclassing
ModelBackendorRemoteUserBackend, review native async implementations as well as sync overrides. Overridingauthenticate(),get_user(), or permission methods alone need not affectaauthenticate(),aget_user(), or async permission checks. - Use
get_user_model()andsettings.AUTH_USER_MODELfor identity lookups and