From c660ad80ce1a2f1fc82fdfaee141c7b4d8124ae0 Mon Sep 17 00:00:00 2001 From: Ludy Date: Wed, 14 May 2025 00:06:14 +0200 Subject: [PATCH] Update legal URLs and improve OpenAPI metadata configuration (#3522) # Description of Changes Please provide a summary of the changes, including: - Updated default Terms & Conditions URL from `/terms-and-conditions` to `/terms` in: - `InitialSetup.java` - `settings.yml.template` - `allEndpointsRemovedSettings.yml` - Improved OpenAPI metadata in `OpenApiConfig.java`: - Added contact information (`name`, `url`, `email`) - Added license section with MIT license - Included terms of service link - Changed string comparison in `MetricsConfig.java` to use `"constant".equals(...)` format - Cleaned up and unified YAML formatting and comments - Merged and restructured `enterpriseEdition` settings under `premium.proFeatures` ### Why the change was made - Ensure legal links are consistent and up-to-date - Improve clarity and completeness of the OpenAPI specification for external consumers - Follow best practices for code readability and configuration structure - Prevent misconfiguration from outdated or redundant YAML sections --- ## 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. --- .../software/SPDF/config/InitialSetup.java | 2 +- .../software/SPDF/config/MetricsConfig.java | 2 +- .../software/SPDF/config/OpenApiConfig.java | 33 +++++++++----- src/main/resources/settings.yml.template | 12 ++--- testing/allEndpointsRemovedSettings.yml | 45 ++++++++++++------- 5 files changed, 58 insertions(+), 36 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/config/InitialSetup.java b/src/main/java/stirling/software/SPDF/config/InitialSetup.java index 44de07d38..0adc3d133 100644 --- a/src/main/java/stirling/software/SPDF/config/InitialSetup.java +++ b/src/main/java/stirling/software/SPDF/config/InitialSetup.java @@ -73,7 +73,7 @@ public class InitialSetup { // Initialize Terms and Conditions String termsUrl = applicationProperties.getLegal().getTermsAndConditions(); if (StringUtils.isEmpty(termsUrl)) { - String defaultTermsUrl = "https://www.stirlingpdf.com/terms-and-conditions"; + String defaultTermsUrl = "https://www.stirlingpdf.com/terms"; GeneralUtils.saveKeyToSettings("legal.termsAndConditions", defaultTermsUrl); applicationProperties.getLegal().setTermsAndConditions(defaultTermsUrl); } diff --git a/src/main/java/stirling/software/SPDF/config/MetricsConfig.java b/src/main/java/stirling/software/SPDF/config/MetricsConfig.java index ba216be75..7012ad517 100644 --- a/src/main/java/stirling/software/SPDF/config/MetricsConfig.java +++ b/src/main/java/stirling/software/SPDF/config/MetricsConfig.java @@ -15,7 +15,7 @@ public class MetricsConfig { return new MeterFilter() { @Override public MeterFilterReply accept(Meter.Id id) { - if (id.getName().equals("http.requests")) { + if ("http.requests".equals(id.getName())) { return MeterFilterReply.NEUTRAL; } return MeterFilterReply.DENY; diff --git a/src/main/java/stirling/software/SPDF/config/OpenApiConfig.java b/src/main/java/stirling/software/SPDF/config/OpenApiConfig.java index d98c33257..d4ff7d167 100644 --- a/src/main/java/stirling/software/SPDF/config/OpenApiConfig.java +++ b/src/main/java/stirling/software/SPDF/config/OpenApiConfig.java @@ -5,7 +5,9 @@ import org.springframework.context.annotation.Configuration; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Contact; import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityScheme; @@ -31,14 +33,25 @@ public class OpenApiConfig { // default version if all else fails version = "1.0.0"; } + Info info = + new Info() + .title(DEFAULT_TITLE) + .version(version) + .license( + new License() + .name("MIT") + .url( + "https://raw.githubusercontent.com/Stirling-Tools/Stirling-PDF/refs/heads/main/LICENSE") + .identifier("MIT")) + .termsOfService("https://www.stirlingpdf.com/terms") + .contact( + new Contact() + .name("Stirling Software") + .url("https://www.stirlingpdf.com") + .email("contact@stirlingpdf.com")) + .description(DEFAULT_DESCRIPTION); if (!applicationProperties.getSecurity().getEnableLogin()) { - return new OpenAPI() - .components(new Components()) - .info( - new Info() - .title(DEFAULT_TITLE) - .version(version) - .description(DEFAULT_DESCRIPTION)); + return new OpenAPI().components(new Components()).info(info); } else { SecurityScheme apiKeyScheme = new SecurityScheme() @@ -47,11 +60,7 @@ public class OpenApiConfig { .name("X-API-KEY"); return new OpenAPI() .components(new Components().addSecuritySchemes("apiKey", apiKeyScheme)) - .info( - new Info() - .title(DEFAULT_TITLE) - .version(version) - .description(DEFAULT_DESCRIPTION)) + .info(info) .addSecurityItem(new SecurityRequirement().addList("apiKey")); } } diff --git a/src/main/resources/settings.yml.template b/src/main/resources/settings.yml.template index 201f875dd..380faeb42 100644 --- a/src/main/resources/settings.yml.template +++ b/src/main/resources/settings.yml.template @@ -77,7 +77,7 @@ premium: appId: '' mail: - enabled: true # set to 'true' to enable sending emails + enabled: false # set to 'true' to enable sending emails host: smtp.example.com # SMTP server hostname port: 587 # SMTP server port username: '' # SMTP server username @@ -85,7 +85,7 @@ mail: from: '' # sender email address legal: - termsAndConditions: https://www.stirlingpdf.com/terms-and-conditions # URL to the terms and conditions of your application (e.g. https://example.com/terms). Empty string to disable or filename to load from local file in static folder + termsAndConditions: https://www.stirlingpdf.com/terms # URL to the terms and conditions of your application (e.g. https://example.com/terms). Empty string to disable or filename to load from local file in static folder privacyPolicy: https://www.stirlingpdf.com/privacy-policy # URL to the privacy policy of your application (e.g. https://example.com/privacy). Empty string to disable or filename to load from local file in static folder accessibilityStatement: '' # URL to the accessibility statement of your application (e.g. https://example.com/accessibility). Empty string to disable or filename to load from local file in static folder cookiePolicy: '' # URL to the cookie policy of your application (e.g. https://example.com/cookie). Empty string to disable or filename to load from local file in static folder @@ -113,11 +113,11 @@ system: name: postgres # set the name of your database. Should match the name of the database you create customPaths: pipeline: - watchedFoldersDir: '' #Defaults to /pipeline/watchedFolders - finishedFoldersDir: '' #Defaults to /pipeline/finishedFolders + watchedFoldersDir: '' # Defaults to /pipeline/watchedFolders + finishedFoldersDir: '' # Defaults to /pipeline/finishedFolders operations: - weasyprint: '' #Defaults to /opt/venv/bin/weasyprint - unoconvert: '' #Defaults to /opt/venv/bin/unoconvert + weasyprint: '' # Defaults to /opt/venv/bin/weasyprint + unoconvert: '' # Defaults to /opt/venv/bin/unoconvert fileUploadLimit: '' # Defaults to "". No limit when string is empty. Set a number, between 0 and 999, followed by one of the following strings to set a limit. "KB", "MB", "GB". ui: diff --git a/testing/allEndpointsRemovedSettings.yml b/testing/allEndpointsRemovedSettings.yml index fa83e2ff0..3290d6fef 100644 --- a/testing/allEndpointsRemovedSettings.yml +++ b/testing/allEndpointsRemovedSettings.yml @@ -11,7 +11,6 @@ # If you want to override with environment parameter follow parameter naming SECURITY_INITIALLOGIN_USERNAME # ############################################################################################################# - security: enableLogin: false # set to 'true' to enable login csrfDisabled: false # set to 'true' to disable CSRF protection (not recommended for production) @@ -62,18 +61,32 @@ security: privateKey: classpath:saml-private-key.key # Your private key. Generated from your keypair spCert: classpath:saml-public-cert.crt # Your signing certificate. Generated from your keypair -enterpriseEdition: - enabled: false # set to 'true' to enable enterprise edition +premium: key: 00000000-0000-0000-0000-000000000000 - SSOAutoLogin: false # Enable to auto login to first provided SSO - CustomMetadata: - autoUpdateMetadata: false # set to 'true' to automatically update metadata with below values - author: username # supports text such as 'John Doe' or types such as username to autopopulate with user's username - creator: Stirling-PDF # supports text such as 'Company-PDF' - producer: Stirling-PDF # supports text such as 'Company-PDF' + enabled: false # Enable license key checks for pro/enterprise features + proFeatures: + SSOAutoLogin: false + CustomMetadata: + autoUpdateMetadata: false # set to 'true' to automatically update metadata with below values + author: username # supports text such as 'John Doe' or types such as username to autopopulate with user's username + creator: Stirling-PDF # supports text such as 'Company-PDF' + producer: Stirling-PDF # supports text such as 'Company-PDF' + googleDrive: + enabled: false + clientId: '' + apiKey: '' + appId: '' + +mail: + enabled: false # set to 'true' to enable sending emails + host: smtp.example.com # SMTP server hostname + port: 587 # SMTP server port + username: '' # SMTP server username + password: '' # SMTP server password + from: '' # sender email address legal: - termsAndConditions: https://www.stirlingpdf.com/terms-and-conditions # URL to the terms and conditions of your application (e.g. https://example.com/terms). Empty string to disable or filename to load from local file in static folder + termsAndConditions: https://www.stirlingpdf.com/terms # URL to the terms and conditions of your application (e.g. https://example.com/terms). Empty string to disable or filename to load from local file in static folder privacyPolicy: https://www.stirlingpdf.com/privacy-policy # URL to the privacy policy of your application (e.g. https://example.com/privacy). Empty string to disable or filename to load from local file in static folder accessibilityStatement: '' # URL to the accessibility statement of your application (e.g. https://example.com/accessibility). Empty string to disable or filename to load from local file in static folder cookiePolicy: '' # URL to the cookie policy of your application (e.g. https://example.com/cookie). Empty string to disable or filename to load from local file in static folder @@ -88,6 +101,7 @@ system: customHTMLFiles: false # enable to have files placed in /customFiles/templates override the existing template HTML files tessdataDir: /usr/share/tessdata # path to the directory containing the Tessdata files. This setting is relevant for Windows systems. For Windows users, this path should be adjusted to point to the appropriate directory where the Tessdata files are stored. enableAnalytics: true # set to 'true' to enable analytics, set to 'false' to disable analytics; for enterprise users, this is set to true + enableUrlToPDF: false # Set to 'true' to enable URL to PDF, INTERNAL ONLY, known security issues, should not be used externally disableSanitize: false # set to true to disable Sanitize HTML; (can lead to injections in HTML) datasource: enableCustomDatabase: false # Enterprise users ONLY, set this property to 'true' if you would like to use your own custom database configuration @@ -100,13 +114,12 @@ system: name: postgres # set the name of your database. Should match the name of the database you create customPaths: pipeline: - watchedFoldersDir: "" #Defaults to /pipeline/watchedFolders - finishedFoldersDir: "" #Defaults to /pipeline/finishedFolders + watchedFoldersDir: '' # Defaults to /pipeline/watchedFolders + finishedFoldersDir: '' # Defaults to /pipeline/finishedFolders operations: - weasyprint: "" #Defaults to /opt/venv/bin/weasyprint - unoconvert: "" #Defaults to /opt/venv/bin/unoconvert - - + weasyprint: '' # Defaults to /opt/venv/bin/weasyprint + unoconvert: '' # Defaults to /opt/venv/bin/unoconvert + fileUploadLimit: '' # Defaults to "". No limit when string is empty. Set a number, between 0 and 999, followed by one of the following strings to set a limit. "KB", "MB", "GB". ui: appName: '' # application's visible name