Part-DB-server/src/Controller
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
..
AdminPages Check for good measure again, that a user is able to edit an entity in an admin form 2026-03-04 23:06:01 +01:00
ErrorHandling Show the error page in a pop up in prod environment too 2024-03-10 00:12:54 +01:00
.gitignore Initial commit 2019-02-23 16:49:38 +01:00
AttachmentFileController.php Allow to load external images and styles in the HTML sandbox 2026-02-24 23:05:09 +01:00
BatchEdaController.php Enhance KiCad integration: API v2, batch EDA editing, field export control (#1241) 2026-03-01 22:10:13 +01:00
BulkInfoProviderImportController.php Added tests for new DTO objects 2025-09-21 23:07:45 +02:00
GroupController.php Use the route attribute from the correct namespace 2024-03-03 20:37:33 +01:00
HomepageController.php Merged functionality from UpdateAvailableManager and UpdateChecker 2026-02-02 18:44:44 +01:00
InfoProviderController.php Added an web page to quickly add a new part from a web URL 2026-02-01 18:18:58 +01:00
KiCadApiController.php Enhance KiCad integration: API v2, batch EDA editing, field export control (#1241) 2026-03-01 22:10:13 +01:00
LabelController.php Fixed tests 2025-09-07 00:26:24 +02:00
LogController.php Allow to configure default table page length via Settings UI 2024-08-21 22:15:26 +02:00
OAuthClientController.php Applied rector suggestions 2024-06-22 00:31:43 +02:00
PartController.php Ran rector 2026-02-14 23:33:40 +01:00
PartImportExportController.php Fixed exception when trying to export an empty entity list 2025-02-01 20:57:27 +01:00
PartListsController.php Added ID to search options. Fixed seach option by using equal to instead of like for the ID. 2026-01-09 11:37:30 +01:00
ProjectController.php Added generic CSV type option, to highlight the universal nature of the importer 2025-09-06 23:20:07 +02:00
RedirectController.php Moved default language, default timezone and base currency settings to new settings system 2024-08-03 23:14:29 +02:00
ScanController.php Label Scanner Enhancements: LCSC barcode, create part, augmented scanning (#1194) 2026-02-22 21:26:44 +01:00
SecurityController.php Use a symfony form for login form 2026-03-07 00:46:34 +01:00
SelectAPIController.php Added way to batch edit the location of parts with a single stock 2025-03-29 16:21:10 +01:00
SettingsController.php Implemented the ability to set user-defined synonyms/labels for internal element types 2025-11-12 21:35:02 +01:00
StatisticsController.php Use the route attribute from the correct namespace 2024-03-03 20:37:33 +01:00
ToolsController.php Merged functionality from UpdateAvailableManager and UpdateChecker 2026-02-02 18:44:44 +01:00
TreeController.php Use the route attribute from the correct namespace 2024-03-03 20:37:33 +01:00
TypeaheadController.php Ensure that user has read permission to part and category to prevent IPN info leakage 2026-03-04 23:54:18 +01:00
UpdateManagerController.php Add manual backup creation and delete buttons to Update Manager (#1255) 2026-03-07 19:31:00 +01:00
UserController.php Use the route attribute from the correct namespace 2024-03-03 20:37:33 +01:00
UserSettingsController.php Ran rector to convert some our twig extensions to use #[AsTwigXX] attributes 2026-02-14 23:53:31 +01:00
WebauthnKeyRegistrationController.php Use the route attribute from the correct namespace 2024-03-03 20:37:33 +01:00