mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 04:36:48 +00:00
feat(accounts): Django's LoginRequiredMiddleware replaces the package
django-login-required-middleware is dropped; Django 5.1+ ships the same middleware. The login page is already marked login_not_required by Django; email_otp gets the decorator, which replaces LOGIN_REQUIRED_IGNORE_VIEW_NAMES. The datasource still requires login. Existing settings.py files still name the old middleware. A system check (accounts.E002) stops migrate and the server until MIDDLEWARE uses Django's middleware, instead of an ImportError at startup; the README has the steps. A new matrix test walks every URL anonymously: everything outside a short allowlist (login pages, the OpenAPI docs) sends the visitor to the login page, and API views deny with 401/403. It passed with the old middleware first and passes unchanged now.
This commit is contained in:
parent
920f318601
commit
e94d69a524
7 changed files with 80 additions and 5 deletions
|
|
@ -396,7 +396,12 @@ environment=CSRF_TRUSTED_ORIGINS="https://webvirtcloud.example.com"
|
|||
|
||||
Back up `db.sqlite3` before updating (in Docker it lives in the `data` volume).
|
||||
|
||||
Upgrading from Django 4.2: delete `USE_L10N` from `webvirtcloud/settings.py` (Django 5 ignores it). Logging out now needs a POST; links or scripts that call `/accounts/logout/` with GET get 405.
|
||||
Upgrading from Django 4.2, edit `webvirtcloud/settings.py`:
|
||||
|
||||
- in `MIDDLEWARE`, replace `"login_required.middleware.LoginRequiredMiddleware"` with `"django.contrib.auth.middleware.LoginRequiredMiddleware"` (the old package is no longer a dependency; `migrate` refuses to run until this is done);
|
||||
- delete `LOGIN_REQUIRED_IGNORE_VIEW_NAMES` and `USE_L10N`.
|
||||
|
||||
Logging out now needs a POST; links or scripts that call `/accounts/logout/` with GET get 405.
|
||||
|
||||
Before running migrations, add `accounts.middleware.ForcePasswordChangeMiddleware`
|
||||
to `MIDDLEWARE` in your existing `webvirtcloud/settings.py`, after
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue