Stirling-PDF/src/main/java/stirling/software/SPDF/config
Ludy e328833f02
Restrict Backup Import to Initialization Process and Refactor API Key Handling (#3061)
# Description of Changes

Please provide a summary of the changes, including:

- **What was changed:**
- Updated the backup import logic in `InitialSecuritySetup` so that the
database backup is only imported during initialization when there are no
users present. If no backup exists, the admin user is initialized
instead.
- Refactored the API key addition in `UserService` by extracting the
logic into a private helper method `saveUser(Optional<User> user)` and
added a call to export the database after updating the user's API key.

- **Why the change was made:**
- To prevent accidental or unintended backup imports outside the
initialization process, ensuring the system only imports backups when
necessary.
- To improve code clarity and maintainability in the user API key
management process, while ensuring that the database state is preserved
via an export after key updates.

Closes https://github.com/Stirling-Tools/Stirling-PDF/discussions/3057

---

## Checklist

### General

- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [x] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md)
(if applicable)
- [x] I have performed a self-review of my own code
- [x] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing)
for more details.
2025-02-25 21:24:01 +00:00
..
fingerprint
interfaces SSO Refactoring (#2818) 2025-02-24 22:18:34 +00:00
security Restrict Backup Import to Initialization Process and Refactor API Key Handling (#3061) 2025-02-25 21:24:01 +00:00
AppConfig.java SSO Refactoring (#2818) 2025-02-24 22:18:34 +00:00
AppUpdateService.java Enhance AppUpdateService: Add @Configuration Annotation for Improved Spring Boot Integration (#3036) 2025-02-23 20:02:46 +00:00
CleanUrlInterceptor.java SSO Refactoring (#2818) 2025-02-24 22:18:34 +00:00
ConfigInitializer.java Config rework (#2823) 2025-01-31 11:00:03 +00:00
EndpointConfiguration.java Dynamic paths for tools and removal of unused book endpoints (#3018) 2025-02-23 13:36:21 +00:00
EndpointInterceptor.java formattingand autowired constructors (#2557) 2024-12-24 09:52:53 +00:00
ExternalAppDepConfig.java Dynamic paths for tools and removal of unused book endpoints (#3018) 2025-02-23 13:36:21 +00:00
FileFallbackTemplateResolver.java File paths dynamic (#2605) 2025-01-06 12:41:30 +00:00
InitialSetup.java Dynamic paths for tools and removal of unused book endpoints (#3018) 2025-02-23 13:36:21 +00:00
InstallationPathConfig.java Dynamic paths for tools and removal of unused book endpoints (#3018) 2025-02-23 13:36:21 +00:00
LocaleConfiguration.java formattingand autowired constructors (#2557) 2024-12-24 09:52:53 +00:00
LogbackPropertyLoader.java File paths dynamic (#2605) 2025-01-06 12:41:30 +00:00
MetricsConfig.java
MetricsFilter.java Dynamic paths for tools and removal of unused book endpoints (#3018) 2025-02-23 13:36:21 +00:00
OpenApiConfig.java formattingand autowired constructors (#2557) 2024-12-24 09:52:53 +00:00
PostHogConfig.java Dynamic paths for tools and removal of unused book endpoints (#3018) 2025-02-23 13:36:21 +00:00
PostHogLoggerImpl.java Posthog to log to log file (#2813) 2025-01-30 15:13:42 +00:00
RuntimePathConfig.java dynamic port for UI from 8080 up (8081 etc) (#3042) 2025-02-24 10:19:43 +00:00
StartupApplicationListener.java
WebMvcConfig.java File paths dynamic (#2605) 2025-01-06 12:41:30 +00:00
YamlPropertySourceFactory.java File paths dynamic (#2605) 2025-01-06 12:41:30 +00:00