Django Authentication 6.0
Last reviewed Sep 20, 2026
Prompt Details
Prompt Composition
3prompts
- Python 3155 lines · 3.8K tokens
- Django 6.0110 lines · 4.1K tokens
- Django Authentication 6.073 lines · 3.5K tokens
Total338 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.0 prompt first. These rules cover django.contrib.auth in Django 6.0.8 on Python 3.12–3.14, including custom backends, password recovery, authenticated session lifecycle, remote-user authentication, and permission administration. Apply separate guidance for the actual MFA, OAuth/OIDC, or API-token implementation when one is installed.
Identity and authentication backends
- Treat
AUTHENTICATION_BACKENDSordering as security policy: authentication stops at the first successful backend. Do not add a local-password fallback that bypasses required external authentication, and invalidate existing sessions when a policy change must force reauthentication; Django reuses the backend path stored in each session. - Enforce account eligibility in custom
get_user()andaget_user()implementations as well as credential authentication.login()does not checkis_active, and neitherlogin_requirednorLoginRequiredMixinsupplies that check; anAllowAllUsers*Backendintentionally bypasses the built-in inactive-user restriction. - Keep the
backendargument tologin()anduser.backendunder server control. Select a configured backend that actually verified the identity; never copy its dotted import path from request data. - Use
get_user_model()andsettings.AUTH_USER_MODELfor user lookups and relations. GiveUSERNAME_FIELDa database-enforced unique identity when usingModelBackend; a nonunique identifier requires a custom backend that unambiguously resolves the account within a trusted scope. - Preserve