From c85463bc1850e0247ca3c2e3e33c5ee54103f2b1 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:34:41 +0100 Subject: [PATCH 01/41] Frooodle/license (#1994) --- .gitignore | 1 - build.gradle | 13 +- cucumber/exampleFiles/example.html | 11 + cucumber/exampleFiles/example.md | 16 + cucumber/exampleFiles/example_html.zip | Bin 0 -> 284 bytes cucumber/features/external.feature | 30 +- .../docker-compose-latest-fat-security.yml | 4 +- .../software/SPDF/EE/EEAppConfig.java | 7 +- .../SPDF/EE/KeygenLicenseVerifier.java | 204 ++++++++++ .../software/SPDF/EE/LicenseKeyChecker.java | 59 +++ .../software/SPDF/LibreOfficeListener.java | 5 +- .../software/SPDF/config/AppConfig.java | 23 ++ .../SPDF/config/AppUpdateService.java | 1 + .../software/SPDF/config/InitialSetup.java | 42 ++ .../{Beans.java => LocaleConfiguration.java} | 2 +- .../software/SPDF/config/MetricsFilter.java | 6 +- .../software/SPDF/config/PostHogConfig.java | 34 ++ .../FingerprintBasedSessionFilter.java | 68 ++++ .../FingerprintBasedSessionManager.java | 134 +++++++ .../fingerprint/FingerprintGenerator.java | 77 ++++ .../DatabaseBackupInterface.java | 2 +- .../{ => interfaces}/ShowAdminInterface.java | 2 +- .../config/security/AppUpdateAuthService.java | 2 +- .../config/security/FirstLoginFilter.java | 21 + .../config/security/InitialSecuritySetup.java | 45 +-- .../security/SecurityConfiguration.java | 277 +++++-------- .../security/UserAuthenticationFilter.java | 33 +- .../SPDF/config/security/UserService.java | 6 +- .../database/DatabaseBackupHelper.java | 2 +- .../saml/ConvertResponseToAuthentication.java | 68 ++++ ...ustomSAMLAuthenticationFailureHandler.java | 51 +++ ...ustomSAMLAuthenticationSuccessHandler.java | 108 +++++ .../saml/SAMLLogoutSuccessHandler.java | 38 ++ .../saml/Saml2AuthorityAttributeLookup.java | 7 + .../Saml2AuthorityAttributeLookupImpl.java | 17 + .../security/saml/SamlAssertionUtils.java | 63 +++ .../SPDF/config/security/saml/SamlConfig.java | 42 ++ .../saml/ScimSaml2AuthenticatedPrincipal.java | 89 ++++ .../security/saml/SimpleScimMappings.java | 10 + .../session/CustomHttpSessionListener.java | 13 +- .../session/SessionPersistentRegistry.java | 8 + .../SPDF/controller/api/CropController.java | 7 +- .../controller/api/SettingsController.java | 37 ++ .../controller/api/SplitPDFController.java | 2 - .../api/SplitPdfByChaptersController.java | 2 +- .../SPDF/controller/api/UserController.java | 8 +- .../ConvertBookToPDFController.java | 6 +- .../api/converters/ConvertHtmlToPDF.java | 28 +- .../api/converters/ConvertMarkdownToPdf.java | 28 +- .../ConvertPDFToBookController.java | 4 +- .../api/converters/ConvertPDFToPDFA.java | 2 +- .../api/misc/ExtractImagesController.java | 2 - .../api/misc/PrintFileController.java | 4 +- .../api/security/RedactController.java | 2 - .../controller/web/GeneralWebController.java | 7 + .../SPDF/model/ApplicationProperties.java | 39 ++ .../software/SPDF/pdf/TextFinder.java | 4 +- .../SPDF/service/CustomPDDocumentFactory.java | 31 +- .../service/MetricsAggregatorService.java | 56 +++ .../PdfMetadataService.java | 59 ++- .../software/SPDF/service/PostHogService.java | 379 ++++++++++++++++++ .../SPDF/utils/CustomHtmlSanitizer.java | 21 + .../software/SPDF/utils/FileToPdf.java | 104 ++++- .../software/SPDF/utils/GeneralUtils.java | 87 ++++ .../software/SPDF/utils/PDFToFile.java | 1 - .../software/SPDF/utils/RequestUriUtils.java | 1 + .../misc/ReplaceAndInvertColorStrategy.java | 3 +- src/main/resources/application.properties | 6 +- src/main/resources/messages_ar_AR.properties | 52 ++- src/main/resources/messages_bg_BG.properties | 50 ++- src/main/resources/messages_ca_CA.properties | 52 ++- src/main/resources/messages_cs_CZ.properties | 52 ++- src/main/resources/messages_da_DK.properties | 50 ++- src/main/resources/messages_de_DE.properties | 52 ++- src/main/resources/messages_el_GR.properties | 50 ++- src/main/resources/messages_en_GB.properties | 58 ++- src/main/resources/messages_en_US.properties | 50 ++- src/main/resources/messages_es_ES.properties | 52 ++- src/main/resources/messages_eu_ES.properties | 50 ++- src/main/resources/messages_fr_FR.properties | 52 ++- src/main/resources/messages_ga_IE.properties | 50 ++- src/main/resources/messages_hi_IN.properties | 50 ++- src/main/resources/messages_hr_HR.properties | 52 ++- src/main/resources/messages_hu_HU.properties | 50 ++- src/main/resources/messages_id_ID.properties | 52 ++- src/main/resources/messages_it_IT.properties | 52 ++- src/main/resources/messages_ja_JP.properties | 52 ++- src/main/resources/messages_ko_KR.properties | 50 ++- src/main/resources/messages_nl_NL.properties | 52 ++- src/main/resources/messages_no_NB.properties | 50 ++- src/main/resources/messages_pl_PL.properties | 52 ++- src/main/resources/messages_pt_BR.properties | 52 ++- src/main/resources/messages_pt_PT.properties | 50 ++- src/main/resources/messages_ro_RO.properties | 50 ++- src/main/resources/messages_ru_RU.properties | 50 ++- src/main/resources/messages_sk_SK.properties | 52 ++- .../resources/messages_sr_LATN_RS.properties | 50 ++- src/main/resources/messages_sv_SE.properties | 50 ++- src/main/resources/messages_th_TH.properties | 50 ++- src/main/resources/messages_tr_TR.properties | 52 ++- src/main/resources/messages_uk_UA.properties | 50 ++- src/main/resources/messages_vi_VN.properties | 50 ++- src/main/resources/messages_zh_CN.properties | 50 ++- src/main/resources/messages_zh_TW.properties | 50 ++- src/main/resources/settings.yml.template | 5 +- .../resources/static/css/bootstrap.min.css | 2 +- src/main/resources/static/css/multi-tool.css | 2 +- src/main/resources/static/css/navbar.css | 31 ++ src/main/resources/static/css/rotate-pdf.css | 13 + src/main/resources/static/js/downloader.js | 23 +- src/main/resources/static/js/favourites.js | 68 +++- src/main/resources/static/js/homecard.js | 54 ++- .../static/js/multitool/PdfActionsManager.js | 1 + .../static/js/multitool/PdfContainer.js | 4 + .../static/js/multitool/horizontalScroll.js | 25 +- src/main/resources/templates/account.html | 6 +- src/main/resources/templates/addUsers.html | 2 + .../resources/templates/fragments/card.html | 2 +- .../resources/templates/fragments/common.html | 44 ++ .../resources/templates/fragments/footer.html | 2 +- .../resources/templates/fragments/navbar.html | 9 + src/main/resources/templates/home.html | 162 ++++++-- .../templates/split-pdf-by-chapters.html | 64 +++ test.sh | 48 +-- 124 files changed, 4399 insertions(+), 577 deletions(-) create mode 100644 cucumber/exampleFiles/example.html create mode 100644 cucumber/exampleFiles/example.md create mode 100644 cucumber/exampleFiles/example_html.zip create mode 100644 src/main/java/stirling/software/SPDF/EE/KeygenLicenseVerifier.java create mode 100644 src/main/java/stirling/software/SPDF/EE/LicenseKeyChecker.java create mode 100644 src/main/java/stirling/software/SPDF/config/InitialSetup.java rename src/main/java/stirling/software/SPDF/config/{Beans.java => LocaleConfiguration.java} (97%) create mode 100644 src/main/java/stirling/software/SPDF/config/PostHogConfig.java create mode 100644 src/main/java/stirling/software/SPDF/config/fingerprint/FingerprintBasedSessionFilter.java create mode 100644 src/main/java/stirling/software/SPDF/config/fingerprint/FingerprintBasedSessionManager.java create mode 100644 src/main/java/stirling/software/SPDF/config/fingerprint/FingerprintGenerator.java rename src/main/java/stirling/software/SPDF/config/{ => interfaces}/DatabaseBackupInterface.java (85%) rename src/main/java/stirling/software/SPDF/config/{ => interfaces}/ShowAdminInterface.java (69%) create mode 100644 src/main/java/stirling/software/SPDF/config/security/saml/ConvertResponseToAuthentication.java create mode 100644 src/main/java/stirling/software/SPDF/config/security/saml/CustomSAMLAuthenticationFailureHandler.java create mode 100644 src/main/java/stirling/software/SPDF/config/security/saml/CustomSAMLAuthenticationSuccessHandler.java create mode 100644 src/main/java/stirling/software/SPDF/config/security/saml/SAMLLogoutSuccessHandler.java create mode 100644 src/main/java/stirling/software/SPDF/config/security/saml/Saml2AuthorityAttributeLookup.java create mode 100644 src/main/java/stirling/software/SPDF/config/security/saml/Saml2AuthorityAttributeLookupImpl.java create mode 100644 src/main/java/stirling/software/SPDF/config/security/saml/SamlAssertionUtils.java create mode 100644 src/main/java/stirling/software/SPDF/config/security/saml/SamlConfig.java create mode 100644 src/main/java/stirling/software/SPDF/config/security/saml/ScimSaml2AuthenticatedPrincipal.java create mode 100644 src/main/java/stirling/software/SPDF/config/security/saml/SimpleScimMappings.java create mode 100644 src/main/java/stirling/software/SPDF/controller/api/SettingsController.java create mode 100644 src/main/java/stirling/software/SPDF/service/MetricsAggregatorService.java rename src/main/java/stirling/software/SPDF/{config => service}/PdfMetadataService.java (62%) create mode 100644 src/main/java/stirling/software/SPDF/service/PostHogService.java create mode 100644 src/main/java/stirling/software/SPDF/utils/CustomHtmlSanitizer.java create mode 100644 src/main/resources/templates/split-pdf-by-chapters.html diff --git a/.gitignore b/.gitignore index ba9d755d98d..c5a8f2e7693 100644 --- a/.gitignore +++ b/.gitignore @@ -110,7 +110,6 @@ watchedFolders/ *.war *.nar *.ear -*.zip *.tar.gz *.rar *.db diff --git a/build.gradle b/build.gradle index 860a574a133..f468388283a 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ ext { } group = "stirling.software" -version = "0.29.0" +version = "0.30.0" java { // 17 is lowest but we support and recommend 21 @@ -32,6 +32,12 @@ java { repositories { mavenCentral() maven { url "https://jitpack.io" } + maven { + url "https://build.shibboleth.net/nexus/content/repositories/releases/" + } + maven { + url "https://build.shibboleth.net/maven/releases/" + } } licenseReport { @@ -127,6 +133,9 @@ dependencies { implementation "org.springframework.boot:spring-boot-starter-jetty:$springBootVersion" implementation "org.springframework.boot:spring-boot-starter-thymeleaf:$springBootVersion" + implementation 'com.posthog.java:posthog:1.1.1' + implementation 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20240325.1' + if (System.getenv("DOCKER_ENABLE_SECURITY") != "false") { implementation "org.springframework.boot:spring-boot-starter-security:$springBootVersion" @@ -134,6 +143,8 @@ dependencies { implementation "org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion" implementation "org.springframework.boot:spring-boot-starter-oauth2-client:$springBootVersion" + implementation 'org.springframework.security:spring-security-saml2-service-provider:6.3.3' + implementation 'com.unboundid.product.scim2:scim2-sdk-client:2.3.5' //2.2.x requires rebuild of DB file.. need migration path runtimeOnly "com.h2database:h2:2.1.214" // implementation "com.h2database:h2:2.2.224" diff --git a/cucumber/exampleFiles/example.html b/cucumber/exampleFiles/example.html new file mode 100644 index 00000000000..82e96100735 --- /dev/null +++ b/cucumber/exampleFiles/example.html @@ -0,0 +1,11 @@ + + +
+ +My first paragraph.
+ + + + diff --git a/cucumber/exampleFiles/example.md b/cucumber/exampleFiles/example.md new file mode 100644 index 00000000000..10bb117bad8 --- /dev/null +++ b/cucumber/exampleFiles/example.md @@ -0,0 +1,16 @@ +header +============ + +Header2 +------------ +text + +text2 + +## **PDF Features** + +### **Page Operations** + +- View and modify PDFs - View multi page PDFs with custom viewing sorting and searching. Plus on page edit features like annotate, draw and adding text and images. (Using PDF.js with Joxit and Liberation.Liberation fonts) +- Full interactive GUI for merging/splitting/rotating/moving PDFs and their pages. +- Merge multiple PDFs together into a single resultant file. \ No newline at end of file diff --git a/cucumber/exampleFiles/example_html.zip b/cucumber/exampleFiles/example_html.zip new file mode 100644 index 0000000000000000000000000000000000000000..23bd1950c444d74aff9bee2916f8d44526dbf80b GIT binary patch literal 284 zcmWIWW@Zs#-~horu8|B-Pz0oT7!(*%D-v@Ha#Hm&N^)~TLwFh33-&Rl*8y=d5SLbP zGcdA%bbyJ?fh8Zy`8s(DLQiO%JiGDn(@l*RJ%4IWb&yg?%6J~V^1-yokeEdeCeE5M zY3B62#rz^H-eL_;E*&Uh?R4#Y>DtLES!MQ%RUoo