From 7109dd790506f700fb000e2c79788f881442912e Mon Sep 17 00:00:00 2001 From: Ludy87 Date: Sun, 19 May 2024 10:52:11 +0200 Subject: [PATCH 1/4] Fix: Removes username validation check - Removes username validation check - Ignores API users in user counting --- .../SPDF/config/security/InitialSecuritySetup.java | 6 ++---- .../software/SPDF/config/security/UserService.java | 8 +++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/config/security/InitialSecuritySetup.java b/src/main/java/stirling/software/SPDF/config/security/InitialSecuritySetup.java index 9ec02e17c..452de53e4 100644 --- a/src/main/java/stirling/software/SPDF/config/security/InitialSecuritySetup.java +++ b/src/main/java/stirling/software/SPDF/config/security/InitialSecuritySetup.java @@ -54,10 +54,8 @@ public class InitialSecuritySetup { && !initialPassword.isEmpty() && !userService.findByUsernameIgnoreCase(initialUsername).isPresent()) { try { - if (userService.isUsernameValid(initialUsername)) { - userService.saveUser(initialUsername, initialPassword, Role.ADMIN.getRoleId()); - logger.info("Admin user created: " + initialUsername); - } + userService.saveUser(initialUsername, initialPassword, Role.ADMIN.getRoleId()); + logger.info("Admin user created: " + initialUsername); } catch (IllegalArgumentException e) { logger.error("Failed to initialize security setup", e); System.exit(1); diff --git a/src/main/java/stirling/software/SPDF/config/security/UserService.java b/src/main/java/stirling/software/SPDF/config/security/UserService.java index 1fcf63f89..0a6898f8a 100644 --- a/src/main/java/stirling/software/SPDF/config/security/UserService.java +++ b/src/main/java/stirling/software/SPDF/config/security/UserService.java @@ -197,7 +197,13 @@ public class UserService implements UserServiceInterface { } public boolean hasUsers() { - return userRepository.count() > 0; + long userCount = userRepository.count(); + if (userRepository + .findByUsernameIgnoreCase(Role.INTERNAL_API_USER.getRoleId()) + .isPresent()) { + userCount -= 1; + } + return userCount > 0; } public void updateUserSettings(String username, Map updates) { From 3f252e29a1b11c2260c8429f90330a80b74ffa83 Mon Sep 17 00:00:00 2001 From: Ludy87 Date: Sun, 19 May 2024 11:35:46 +0200 Subject: [PATCH 2/4] adds all available settings to settings.yml --- README.md | 38 +++++++++++++++++++----- src/main/resources/settings.yml.template | 9 +++++- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7fba0db5d..71ff91b69 100644 --- a/README.md +++ b/README.md @@ -222,27 +222,51 @@ The Current list of settings is ```yaml security: enableLogin: false # set to 'true' to enable login - csrfDisabled: true + csrfDisabled: true # Set to 'true' to disable CSRF protection (not recommended for production) + loginAttemptCount: 5 # lock user account after 5 tries + loginResetTimeMinutes : 120 # lock account for 2 hours after x attempts + # initialLogin: + # username: "admin" # Initial username for the first login + # password: "stirling" # Initial password for the first login + # oauth2: + # enabled: false # set to 'true' to enable login (Note: enableLogin must also be 'true' for this to work) + # issuer: "" # set to any provider that supports OpenID Connect Discovery (/.well-known/openid-configuration) end-point + # clientId: "" # Client ID from your provider + # clientSecret: "" # Client Secret from your provider + # autoCreateUser: false # set to 'true' to allow auto-creation of non-existing users + # useAsUsername: "email" # Default is 'email'; custom fields can be used as the username + # scopes: "openid, profile, email" # Specify the scopes for which the application will request permissions + # provider: "google" # Set this to your OAuth provider's name, e.g., 'google' or 'keycloak' system: defaultLocale: 'en-US' # Set the default language (e.g. 'de-DE', 'fr-FR', etc) googlevisibility: false # 'true' to allow Google visibility (via robots.txt), 'false' to disallow - customStaticFilePath: '/customFiles/static/' # Directory path for custom static files + rootURIPath: '/pdf-app' # ie set to /pdf-app to Set the application's root URI to localhost:8080/pdf-app + customStaticFilePath: '/customFiles/static/' # Customise static files (e.g., logo, images, CSS) by placing them in this directory. + maxFileSize: 10485760 # Maximum file size for uploads in bytes. + enableAlphaFunctionality: false # Set to enable functionality which might need more testing before it fully goes live (This feature might make no changes) showUpdate: true # see when a new update is available showUpdateOnlyAdmin: false # Only admins can see when a new update is available, depending on showUpdate it must be set to 'true' customHTMLFiles: false # enable to have files placed in /customFiles/templates override the existing template html files -#ui: -# appName: exampleAppName # Application's visible name -# homeDescription: I am a description # Short description or tagline shown on homepage. -# appNameNavbar: navbarName # Name displayed on the navigation bar +ui: + appName: null # Application's visible name + homeDescription: null # Short description or tagline shown on homepage. + appNameNavbar: null # Name displayed on the navigation bar endpoints: toRemove: [] # List endpoints to disable (e.g. ['img-to-pdf', 'remove-pages']) groupsToRemove: [] # List groups to disable (e.g. ['LibreOffice']) metrics: - enabled: true # 'true' to enable Info APIs endpoints (view http://localhost:8080/swagger-ui/index.html#/API to learn more), 'false' to disable + enabled: true # 'true' to enable Info APIs (`/api/*`) endpoints, 'false' to disable + +autoPipeline: + outputFolder: /output # Directory for auto-pipeline outputs. + +# Automatically Generated Settings (Do Not Edit Directly) +AutomaticallyGenerated: + key: example ``` There is an additional config file ``/configs/custom_settings.yml`` were users familiar with java and spring application.properties can input their own settings on-top of Stirling-PDFs existing ones diff --git a/src/main/resources/settings.yml.template b/src/main/resources/settings.yml.template index d7d1fcfa2..d504e82e3 100644 --- a/src/main/resources/settings.yml.template +++ b/src/main/resources/settings.yml.template @@ -4,9 +4,12 @@ security: enableLogin: false # set to 'true' to enable login - csrfDisabled: true + csrfDisabled: true # Set to 'true' to disable CSRF protection (not recommended for production) loginAttemptCount: 5 # lock user account after 5 tries loginResetTimeMinutes : 120 # lock account for 2 hours after x attempts + # initialLogin: + # username: "admin" # Initial username for the first login + # password: "stirling" # Initial password for the first login # oauth2: # enabled: false # set to 'true' to enable login (Note: enableLogin must also be 'true' for this to work) # issuer: "" # set to any provider that supports OpenID Connect Discovery (/.well-known/openid-configuration) end-point @@ -20,9 +23,13 @@ security: system: defaultLocale: 'en-US' # Set the default language (e.g. 'de-DE', 'fr-FR', etc) googlevisibility: false # 'true' to allow Google visibility (via robots.txt), 'false' to disallow + rootURIPath: '/pdf-app' # ie set to /pdf-app to Set the application's root URI to localhost:8080/pdf-app + customStaticFilePath: '/customFiles/static/' # Customise static files (e.g., logo, images, CSS) by placing them in this directory. + maxFileSize: 10485760 # Maximum file size for uploads in bytes. enableAlphaFunctionality: false # Set to enable functionality which might need more testing before it fully goes live (This feature might make no changes) showUpdate: true # see when a new update is available showUpdateOnlyAdmin: false # Only admins can see when a new update is available, depending on showUpdate it must be set to 'true' + customHTMLFiles: false # enable to have files placed in /customFiles/templates override the existing template html files ui: appName: null # Application's visible name From ffe221b93c08ce3d4a8466ecde968f0d8342e866 Mon Sep 17 00:00:00 2001 From: Ludy87 Date: Sun, 19 May 2024 11:36:50 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 71ff91b69..509286302 100644 --- a/README.md +++ b/README.md @@ -263,10 +263,6 @@ metrics: autoPipeline: outputFolder: /output # Directory for auto-pipeline outputs. - -# Automatically Generated Settings (Do Not Edit Directly) -AutomaticallyGenerated: - key: example ``` There is an additional config file ``/configs/custom_settings.yml`` were users familiar with java and spring application.properties can input their own settings on-top of Stirling-PDFs existing ones From f2eb5dd7d3f5c67451663144322845db4fa1a644 Mon Sep 17 00:00:00 2001 From: Ludy87 Date: Sun, 19 May 2024 12:44:54 +0200 Subject: [PATCH 4/4] bg-card will be added to the class and password/username validation bg-card should not be an id, ids should be unique in their use. --- src/main/resources/static/css/multi-tool.css | 2 +- .../static/css/theme/componentes.css | 2 +- src/main/resources/templates/about.html | 2 +- src/main/resources/templates/account.html | 81 ++++++++++++++++++- src/main/resources/templates/addUsers.html | 2 +- .../resources/templates/auto-split-pdf.html | 2 +- .../resources/templates/change-creds.html | 2 +- .../templates/convert/file-to-pdf.html | 2 +- .../templates/convert/html-to-pdf.html | 2 +- .../templates/convert/img-to-pdf.html | 2 +- .../templates/convert/markdown-to-pdf.html | 2 +- .../templates/convert/pdf-to-csv.html | 2 +- .../templates/convert/pdf-to-html.html | 2 +- .../templates/convert/pdf-to-img.html | 2 +- .../templates/convert/pdf-to-pdfa.html | 2 +- .../convert/pdf-to-presentation.html | 2 +- .../templates/convert/pdf-to-text.html | 2 +- .../templates/convert/pdf-to-word.html | 2 +- .../templates/convert/pdf-to-xml.html | 2 +- .../templates/convert/url-to-pdf.html | 2 +- src/main/resources/templates/crop.html | 2 +- src/main/resources/templates/error.html | 2 +- .../resources/templates/extract-page.html | 2 +- src/main/resources/templates/licenses.html | 2 +- src/main/resources/templates/merge-pdfs.html | 2 +- .../resources/templates/misc/add-image.html | 2 +- .../templates/misc/add-page-numbers.html | 2 +- .../templates/misc/adjust-contrast.html | 2 +- .../resources/templates/misc/auto-crop.html | 2 +- .../resources/templates/misc/auto-rename.html | 2 +- .../templates/misc/change-metadata.html | 2 +- .../resources/templates/misc/compare.html | 2 +- .../templates/misc/compress-pdf.html | 2 +- .../templates/misc/extract-image-scans.html | 2 +- .../templates/misc/extract-images.html | 2 +- .../resources/templates/misc/flatten.html | 2 +- .../resources/templates/misc/ocr-pdf.html | 2 +- .../templates/misc/remove-annotations.html | 2 +- .../templates/misc/remove-blanks.html | 2 +- src/main/resources/templates/misc/repair.html | 2 +- .../templates/misc/show-javascript.html | 2 +- src/main/resources/templates/misc/stamp.html | 2 +- .../templates/multi-page-layout.html | 2 +- src/main/resources/templates/multi-tool.html | 2 +- src/main/resources/templates/overlay-pdf.html | 2 +- .../resources/templates/pdf-organizer.html | 2 +- .../templates/pdf-to-single-page.html | 2 +- src/main/resources/templates/pipeline.html | 2 +- .../resources/templates/remove-pages.html | 2 +- src/main/resources/templates/rotate-pdf.html | 2 +- src/main/resources/templates/scale-pages.html | 2 +- .../templates/security/add-password.html | 2 +- .../templates/security/add-watermark.html | 2 +- .../templates/security/auto-redact.html | 2 +- .../templates/security/cert-sign.html | 2 +- .../security/change-permissions.html | 2 +- .../templates/security/get-info-on-pdf.html | 2 +- .../templates/security/remove-password.html | 2 +- .../templates/security/remove-watermark.html | 2 +- .../templates/security/sanitize-pdf.html | 2 +- src/main/resources/templates/sign.html | 2 +- .../templates/split-by-size-or-count.html | 2 +- .../templates/split-pdf-by-sections.html | 2 +- src/main/resources/templates/split-pdfs.html | 2 +- 64 files changed, 140 insertions(+), 67 deletions(-) diff --git a/src/main/resources/static/css/multi-tool.css b/src/main/resources/static/css/multi-tool.css index f9c359dc6..0e609652b 100644 --- a/src/main/resources/static/css/multi-tool.css +++ b/src/main/resources/static/css/multi-tool.css @@ -65,7 +65,7 @@ label { margin-left: auto; } -#bg-card { +.bg-card { background-color: var(--md-sys-color-surface-5); border-radius: 3rem; padding: 25px 0 0; diff --git a/src/main/resources/static/css/theme/componentes.css b/src/main/resources/static/css/theme/componentes.css index d588d6869..d767d59d0 100644 --- a/src/main/resources/static/css/theme/componentes.css +++ b/src/main/resources/static/css/theme/componentes.css @@ -58,7 +58,7 @@ td { border-bottom: none; } -#bg-card { +.bg-card { background-color: var(--md-sys-color-surface-5); border-radius: 3rem; padding: 2.5rem; diff --git a/src/main/resources/templates/about.html b/src/main/resources/templates/about.html index c29d2ffad..c315ce747 100644 --- a/src/main/resources/templates/about.html +++ b/src/main/resources/templates/about.html @@ -11,7 +11,7 @@

-
+
diff --git a/src/main/resources/templates/account.html b/src/main/resources/templates/account.html index 727de2245..e07050ffd 100644 --- a/src/main/resources/templates/account.html +++ b/src/main/resources/templates/account.html @@ -21,6 +21,7 @@ Default message if not found +

User!

@@ -28,13 +29,15 @@ Error Message +

Change Username?

-
+
+
@@ -49,10 +52,10 @@

Change Password?

- +
- +
@@ -95,6 +98,76 @@
+

Sync browser settings with Account

-
+

Settings Comparison:

diff --git a/src/main/resources/templates/addUsers.html b/src/main/resources/templates/addUsers.html index e87726cf4..4657ecd9e 100644 --- a/src/main/resources/templates/addUsers.html +++ b/src/main/resources/templates/addUsers.html @@ -12,7 +12,7 @@

-
+

Admin User Control Settings

diff --git a/src/main/resources/templates/auto-split-pdf.html b/src/main/resources/templates/auto-split-pdf.html index fa6b1d167..3e93c565c 100644 --- a/src/main/resources/templates/auto-split-pdf.html +++ b/src/main/resources/templates/auto-split-pdf.html @@ -15,7 +15,7 @@

-
+
cut diff --git a/src/main/resources/templates/change-creds.html b/src/main/resources/templates/change-creds.html index 30e066885..adef8b556 100644 --- a/src/main/resources/templates/change-creds.html +++ b/src/main/resources/templates/change-creds.html @@ -12,7 +12,7 @@

-
+

User Settings

diff --git a/src/main/resources/templates/convert/file-to-pdf.html b/src/main/resources/templates/convert/file-to-pdf.html index f822a5930..1386a4410 100644 --- a/src/main/resources/templates/convert/file-to-pdf.html +++ b/src/main/resources/templates/convert/file-to-pdf.html @@ -14,7 +14,7 @@

-
+
draft diff --git a/src/main/resources/templates/convert/html-to-pdf.html b/src/main/resources/templates/convert/html-to-pdf.html index 94b4f8428..ff0bf143e 100644 --- a/src/main/resources/templates/convert/html-to-pdf.html +++ b/src/main/resources/templates/convert/html-to-pdf.html @@ -12,7 +12,7 @@

-
+
html diff --git a/src/main/resources/templates/convert/img-to-pdf.html b/src/main/resources/templates/convert/img-to-pdf.html index ec49e1c4e..09d0461b7 100644 --- a/src/main/resources/templates/convert/img-to-pdf.html +++ b/src/main/resources/templates/convert/img-to-pdf.html @@ -12,7 +12,7 @@

-
+
image diff --git a/src/main/resources/templates/convert/markdown-to-pdf.html b/src/main/resources/templates/convert/markdown-to-pdf.html index 748c5c663..af93f23c5 100644 --- a/src/main/resources/templates/convert/markdown-to-pdf.html +++ b/src/main/resources/templates/convert/markdown-to-pdf.html @@ -12,7 +12,7 @@

-
+
markdown diff --git a/src/main/resources/templates/convert/pdf-to-csv.html b/src/main/resources/templates/convert/pdf-to-csv.html index be78d1da0..23f804b09 100644 --- a/src/main/resources/templates/convert/pdf-to-csv.html +++ b/src/main/resources/templates/convert/pdf-to-csv.html @@ -11,7 +11,7 @@

-
+
csv diff --git a/src/main/resources/templates/convert/pdf-to-html.html b/src/main/resources/templates/convert/pdf-to-html.html index 395f98296..5006ad1b5 100644 --- a/src/main/resources/templates/convert/pdf-to-html.html +++ b/src/main/resources/templates/convert/pdf-to-html.html @@ -12,7 +12,7 @@

-
+
html diff --git a/src/main/resources/templates/convert/pdf-to-img.html b/src/main/resources/templates/convert/pdf-to-img.html index d6b5f871a..a0402fc15 100644 --- a/src/main/resources/templates/convert/pdf-to-img.html +++ b/src/main/resources/templates/convert/pdf-to-img.html @@ -12,7 +12,7 @@

-
+
image diff --git a/src/main/resources/templates/convert/pdf-to-pdfa.html b/src/main/resources/templates/convert/pdf-to-pdfa.html index 7b51a86c5..98f1565cf 100644 --- a/src/main/resources/templates/convert/pdf-to-pdfa.html +++ b/src/main/resources/templates/convert/pdf-to-pdfa.html @@ -12,7 +12,7 @@

-
+
picture_as_pdf diff --git a/src/main/resources/templates/convert/pdf-to-presentation.html b/src/main/resources/templates/convert/pdf-to-presentation.html index 8d4a42845..fcef6e65c 100644 --- a/src/main/resources/templates/convert/pdf-to-presentation.html +++ b/src/main/resources/templates/convert/pdf-to-presentation.html @@ -12,7 +12,7 @@

-
+
slideshow diff --git a/src/main/resources/templates/convert/pdf-to-text.html b/src/main/resources/templates/convert/pdf-to-text.html index 21bf1fae7..e0fc5fbbb 100644 --- a/src/main/resources/templates/convert/pdf-to-text.html +++ b/src/main/resources/templates/convert/pdf-to-text.html @@ -12,7 +12,7 @@

-
+
text_fields diff --git a/src/main/resources/templates/convert/pdf-to-word.html b/src/main/resources/templates/convert/pdf-to-word.html index cce75d761..c17c2675b 100644 --- a/src/main/resources/templates/convert/pdf-to-word.html +++ b/src/main/resources/templates/convert/pdf-to-word.html @@ -12,7 +12,7 @@

-
+
description diff --git a/src/main/resources/templates/convert/pdf-to-xml.html b/src/main/resources/templates/convert/pdf-to-xml.html index 388ed80b1..8ee1237e9 100644 --- a/src/main/resources/templates/convert/pdf-to-xml.html +++ b/src/main/resources/templates/convert/pdf-to-xml.html @@ -12,7 +12,7 @@

-
+
code diff --git a/src/main/resources/templates/convert/url-to-pdf.html b/src/main/resources/templates/convert/url-to-pdf.html index 26c13ad15..03f26e9dc 100644 --- a/src/main/resources/templates/convert/url-to-pdf.html +++ b/src/main/resources/templates/convert/url-to-pdf.html @@ -12,7 +12,7 @@

-
+
link diff --git a/src/main/resources/templates/crop.html b/src/main/resources/templates/crop.html index 0af2509c8..fdb248fdf 100644 --- a/src/main/resources/templates/crop.html +++ b/src/main/resources/templates/crop.html @@ -11,7 +11,7 @@

-
+
crop diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html index 61c69c245..fd357afbe 100644 --- a/src/main/resources/templates/error.html +++ b/src/main/resources/templates/error.html @@ -10,7 +10,7 @@
-
+

diff --git a/src/main/resources/templates/extract-page.html b/src/main/resources/templates/extract-page.html index 1f8feec28..05d171ce3 100644 --- a/src/main/resources/templates/extract-page.html +++ b/src/main/resources/templates/extract-page.html @@ -11,7 +11,7 @@

-
+
upload diff --git a/src/main/resources/templates/licenses.html b/src/main/resources/templates/licenses.html index c91a4507c..a2f81653e 100644 --- a/src/main/resources/templates/licenses.html +++ b/src/main/resources/templates/licenses.html @@ -11,7 +11,7 @@

-
+

3rd Party licenses

diff --git a/src/main/resources/templates/merge-pdfs.html b/src/main/resources/templates/merge-pdfs.html index c8579fc08..d810fdc4a 100644 --- a/src/main/resources/templates/merge-pdfs.html +++ b/src/main/resources/templates/merge-pdfs.html @@ -12,7 +12,7 @@

-
+
add_to_photos diff --git a/src/main/resources/templates/misc/add-image.html b/src/main/resources/templates/misc/add-image.html index 40146ed23..21ecfdc78 100644 --- a/src/main/resources/templates/misc/add-image.html +++ b/src/main/resources/templates/misc/add-image.html @@ -13,7 +13,7 @@

-
+
add_photo_alternate diff --git a/src/main/resources/templates/misc/add-page-numbers.html b/src/main/resources/templates/misc/add-page-numbers.html index a118a4c26..ea8281c81 100644 --- a/src/main/resources/templates/misc/add-page-numbers.html +++ b/src/main/resources/templates/misc/add-page-numbers.html @@ -55,7 +55,7 @@

-
+
123 diff --git a/src/main/resources/templates/misc/adjust-contrast.html b/src/main/resources/templates/misc/adjust-contrast.html index 1f381e03e..b4811495a 100644 --- a/src/main/resources/templates/misc/adjust-contrast.html +++ b/src/main/resources/templates/misc/adjust-contrast.html @@ -20,7 +20,7 @@

-
+