Part-DB-server/templates
Sebastian Almberg 0d58262e19
Add manual backup creation and delete buttons to Update Manager (#1255)
* Add manual backup creation and delete buttons to Update Manager

- Add "Create Backup" button in the backups tab for on-demand backups
- Add delete buttons (trash icons) for update logs and backups
- New controller routes with CSRF protection and permission checks
- Use data-turbo-confirm for CSP-safe confirmation dialogs
- Add deleteLog() method to UpdateExecutor with filename validation

* Add Docker backup support: download button, SQLite restore fix, decouple from auto-update

- Decouple backup creation/restore UI from can_auto_update so Docker
  and other non-git installations can use backup features
- Add backup download endpoint for saving backups externally
- Fix SQLite restore to use configured DATABASE_URL path instead of
  hardcoded var/app.db (affects Docker and custom SQLite paths)
- Show Docker-specific warning about var/backups/ not being persisted
- Pass is_docker flag to template via InstallationTypeDetector

* Add tests for backup/update manager improvements

- Controller tests: auth, CSRF validation, 404 for missing backups, restore disabled check
- UpdateExecutor: deleteLog validation, non-existent file, successful deletion
- BackupManager: deleteBackup validation for missing/non-zip files

* Fix test failures: add locale prefix to URLs, correct log directory path

* Fix auth test: expect 401 instead of redirect for HTTP Basic auth

* Improve test coverage for update manager controller

Add happy-path tests for backup creation, deletion, download,
and log deletion with valid CSRF tokens. Also test the locked
state blocking backup creation.

* Fix CSRF tests: initialize session before getting tokens

* Fix CSRF tests: extract tokens from rendered page HTML

* Harden backup security: password confirmation, CSRF, env toggle

Address security review feedback from jbtronics:

- Add IS_AUTHENTICATED_FULLY to all sensitive endpoints (create/delete
  backup, delete log, download backup, start update, restore)
- Change backup download from GET to POST with CSRF token
- Require password confirmation before downloading backups (backups
  contain sensitive data like password hashes and secrets)
- Add DISABLE_BACKUP_DOWNLOAD env var (default: disabled) to control
  whether backup downloads are allowed
- Add password confirmation modal with security warning in template
- Add comprehensive tests: auth checks, env var blocking, POST-only
  enforcement, status/progress endpoint auth

* Fix download modal: use per-backup modals for CSP/Turbo compatibility

- Replace shared modal + inline JS with per-backup modals that have
  filename pre-set in hidden fields (no JavaScript needed)
- Add data-turbo="false" to download forms for native browser handling
- Add data-bs-dismiss="modal" to submit button to auto-close modal
- Add hidden username field for Chrome accessibility best practice
- Fix test: GET on POST-only route returns 404 not 405

* Fixed translation keys

* Fixed text justification in download modal

* Hardenened security of deleteLogEndpoint

* Show whether backup, restores and updates are allowed or disabled by sysadmin on update manager

* Added documentation for update manager related env variables

---------

Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
2026-03-07 19:31:00 +01:00
..
admin Add manual backup creation and delete buttons to Update Manager (#1255) 2026-03-07 19:31:00 +01:00
attachments Allow file downloads and modals in HTML sandbox 2026-02-24 22:57:48 +01:00
bundles/TwigBundle/Exception Add cache pool clear hint to error pages 2026-03-04 23:27:06 +01:00
components Enhance KiCad integration: API v2, batch EDA editing, field export control (#1241) 2026-03-01 22:10:13 +01:00
form Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
info_providers Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
label_system Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
log_system Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
mail Use new settings system to configure the instance Name and homepage banner 2024-05-20 21:14:32 +02:00
parts Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
projects Use yellow alert box for notifying of empty bom on build, show infinite correclty and added translations 2025-10-18 23:32:20 +02:00
security Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
settings Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
tools Merge branch 'master' into settings-bundle 2025-01-17 22:06:18 +01:00
users Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
_navbar.html.twig Added a "create from label scan button to navbar" 2026-02-22 22:03:46 +01:00
_sidebar.html.twig Allow to configure sidebar menu via the new settings system 2024-08-07 00:41:06 +02:00
_toast.html.twig Improved styling of a info level flash toast in darkmode 2023-07-03 22:01:39 +02:00
_toast_container.html.twig Fixed toast position on large screens 2023-02-06 22:47:41 +01:00
_turbo_control.html.twig Fixed flash messages in admin pages 2026-03-04 23:24:29 +01:00
attachment_list.html.twig Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
base.html.twig Navigate only the content frame when submitting the global barcode scan label 2026-03-01 16:56:47 +01:00
helper.twig Add manual backup creation and delete buttons to Update Manager (#1255) 2026-03-07 19:31:00 +01:00
homepage.html.twig Allow to hide the version number on homepage 2025-09-07 19:43:23 +02:00
main_card.html.twig Added a very basic import dialog for Parts 2023-03-12 19:53:55 +01:00
vars.macro.twig Fixed old usages of base_currency 2024-08-03 23:19:09 +02:00