wip - fixing fe bug

This commit is contained in:
Dario Ghunney Ware 2025-05-15 10:01:18 +01:00
parent 9091281ae4
commit 3ced047760
16 changed files with 112 additions and 44 deletions

View File

@ -29,9 +29,6 @@ ext {
tempJrePath = null
}
group = "stirling.software"
version = "0.46.1"
// todo: package jar with option for enterprise features to be included
jar {
enabled = false
@ -46,6 +43,9 @@ bootJar {
}
allprojects {
group = "stirling.software"
version = "0.46.1"
afterEvaluate {
if (project == rootProject) return
tasks.register('wrapper', Wrapper) {
@ -61,8 +61,7 @@ subprojects {
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = "stirling.software"
version = "0.46.1"
java {
// 17 is lowest but we support and recommend 21
@ -148,10 +147,10 @@ sourceSets {
test {
java {
if (System.getenv("DOCKER_ENABLE_SECURITY") == "false") {
exclude "stirling/software/SPDF/config/security/**"
exclude "stirling/software/SPDF/model/ApiKeyAuthenticationTokenTest.java"
exclude "stirling/software/SPDF/controller/api/EmailControllerTest.java"
exclude "stirling/software/SPDF/repository/**"
exclude "stirling/software/spdf/config/security/**"
exclude "stirling/software/spdf/model/ApiKeyAuthenticationTokenTest.java"
exclude "stirling/software/spdf/controller/api/EmailControllerTest.java"
exclude "stirling/software/spdf/repository/**"
}
if (System.getenv("STIRLING_PDF_DESKTOP_UI") == "false") {
@ -475,13 +474,26 @@ swaggerhubUpload {
oas = "3.0.0" // The version of the OpenAPI Specification you"re using
}
tasks.named("test") {
useJUnitPlatform()
}
tasks.register('writeVersion') {
def propsFile = file("$projectDir/stirling-pdf/src/main/resources/version.properties")
def propsDir = propsFile.parentFile
doLast {
if (!propsDir.exists()) {
if (propsDir.exists()) {
if (propsFile.exists()) {
println "File exists: $propsFile"
} else {
println "$propsFile does not exist. Creating file."
propsFile.createNewFile()
}
} else {
println "Creating directory: $propsDir"
propsDir.mkdirs()
propsFile.createNewFile()
}
def props = new Properties()
@ -492,10 +504,6 @@ tasks.register('writeVersion') {
processResources.dependsOn(writeVersion)
tasks.named("test") {
useJUnitPlatform()
}
tasks.register('printVersion') {
doLast {
println project.version

View File

@ -11,6 +11,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20240325.1'
implementation 'com.fathzer:javaluator:3.0.6'
implementation 'com.posthog.java:posthog:1.2.0'
implementation 'io.github.pixee:java-security-toolkit:1.2.1'
implementation 'org.apache.commons:commons-lang3:3.17.0'
implementation 'com.drewnoakes:metadata-extractor:2.19.0' // Image metadata extractor

View File

@ -1,5 +1,6 @@
package stirling.software.common.configuration;
import com.posthog.java.PostHog;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@ -32,9 +33,8 @@ import stirling.software.common.model.ApplicationProperties;
public class AppConfig {
private final Environment env;
private final ApplicationProperties applicationProperties;
private final Environment env;
private final ApplicationProperties applicationProperties;
@Getter
@Value("${baseUrl:http://localhost}")
@ -48,6 +48,12 @@ public class AppConfig {
@Value("${server.port:8080}")
private String serverPort;
@Value("${posthog.apiKey")
private String posthogApiKey;
@Value("${posthog.host}")
private String posthogHost;
@Bean
@ConditionalOnProperty(name = "system.customHTMLFiles", havingValue = "true")
public SpringTemplateEngine templateEngine(ResourceLoader resourceLoader) {
@ -271,4 +277,12 @@ public class AppConfig {
return "Unknown";
}
}
@Bean
public PostHog postHog() {
return new PostHog.Builder(posthogApiKey)
.host(posthogHost)
.logger(new PostHogLoggerImpl())
.build();
}
}

View File

@ -48,25 +48,22 @@ public class InstallationPathConfig {
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("win")) {
return Paths.get(
System.getenv("APPDATA"), // parent path
"Stirling-PDF")
.toString()
+ File.separator;
System.getenv("APPDATA"), // parent path
"Stirling-PDF")
+ File.separator;
} else if (os.contains("mac")) {
return Paths.get(
System.getProperty("user.home"),
"Library",
"Application Support",
"Stirling-PDF")
.toString()
+ File.separator;
System.getProperty("user.home"),
"Library",
"Application Support",
"Stirling-PDF")
+ File.separator;
} else {
return Paths.get(
System.getProperty("user.home"), // parent path
".config",
"Stirling-PDF")
.toString()
+ File.separator;
System.getProperty("user.home"), // parent path
".config",
"Stirling-PDF")
+ File.separator;
}
}
return "." + File.separator;

View File

@ -1,4 +1,4 @@
package stirling.software.spdf.config;
package stirling.software.common.configuration;
import org.springframework.stereotype.Component;

View File

@ -1,4 +1,4 @@
package stirling.software.spdf.service;
package stirling.software.common.service;
import java.io.File;
import java.lang.management.GarbageCollectorMXBean;
@ -26,7 +26,6 @@ import org.springframework.stereotype.Service;
import com.posthog.java.PostHog;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.service.UserServiceInterface;
@Service
public class PostHogService {

View File

@ -59,7 +59,6 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-jetty'
implementation 'io.swagger.core.v3:swagger-core-jakarta:2.2.30'
implementation 'com.posthog.java:posthog:1.2.0'
implementation 'com.bucket4j:bucket4j_jdk17-core:8.14.0' // https://mvnrepository.com/artifact/com.bucket4j/bucket4j_jdk17
implementation 'org.bouncycastle:bcprov-jdk18on:1.80'

View File

@ -1,6 +1,6 @@
package stirling.software.spdf.EE.configuration;
package stirling.software.spdf.EE;
import static stirling.software.spdf.EE.configuration.KeygenLicenseVerifier.License;
import static stirling.software.spdf.EE.KeygenLicenseVerifier.License;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;

View File

@ -1,4 +1,4 @@
package stirling.software.spdf.EE.configuration;
package stirling.software.spdf.EE;
import java.net.URI;
import java.net.http.HttpClient;

View File

@ -1,4 +1,4 @@
package stirling.software.spdf.EE.configuration;
package stirling.software.spdf.EE;
import java.io.IOException;
import java.nio.file.Files;
@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
import lombok.extern.slf4j.Slf4j;
import stirling.software.spdf.EE.configuration.KeygenLicenseVerifier.License;
import stirling.software.spdf.EE.KeygenLicenseVerifier.License;
import stirling.software.common.model.ApplicationProperties;
import stirling.software.common.util.GeneralUtil;

View File

@ -59,7 +59,7 @@ public class InitialSetup {
public void initEnableCSRFSecurity() throws IOException {
if (GeneralUtil.isVersionHigher(
"0.36.0", applicationProperties.getAutomaticallyGenerated().getAppVersion())) {
"0.46.0", applicationProperties.getAutomaticallyGenerated().getAppVersion())) {
Boolean csrf = applicationProperties.getSecurity().getCsrfDisabled();
if (!csrf) {
GeneralUtil.saveKeyToSettings("security.csrfDisabled", false);

View File

@ -25,7 +25,11 @@ public class WebMvcConfig implements WebMvcConfigurer {
// Handler for external static resources
registry.addResourceHandler("/**")
.addResourceLocations(
"file:" + InstallationPathConfig.getStaticPath(), "classpath:/static/");
"classpath:/stirling-pdf/src/main/resources/static/",
"classpath:/stirling-pdf/static/",
"classpath:/static/",
"file:" + InstallationPathConfig.getStaticPath()
);
// .setCachePeriod(0); // Optional: disable caching
}
}

View File

@ -30,7 +30,7 @@ import stirling.software.spdf.model.PipelineConfig;
import stirling.software.spdf.model.PipelineOperation;
import stirling.software.spdf.model.PipelineResult;
import stirling.software.spdf.model.api.HandleDataRequest;
import stirling.software.spdf.service.PostHogService;
import stirling.software.common.service.PostHogService;
import stirling.software.common.util.WebResponseUtils;
@RestController

View File

@ -36,7 +36,7 @@ import stirling.software.spdf.model.PipelineConfig;
import stirling.software.spdf.model.PipelineOperation;
import stirling.software.spdf.model.PipelineResult;
import stirling.software.spdf.service.ApiDocService;
import stirling.software.spdf.service.PostHogService;
import stirling.software.common.service.PostHogService;
import stirling.software.common.configuration.RuntimePathConfig;
import stirling.software.common.util.FileMonitor;

View File

@ -14,6 +14,7 @@ import io.micrometer.core.instrument.search.Search;
import lombok.RequiredArgsConstructor;
import stirling.software.common.service.PostHogService;
import stirling.software.spdf.config.EndpointInspector;
@Service

View File

@ -0,0 +1,45 @@
multipart.enabled=true
logging.level.org.springframework=WARN
logging.level.org.hibernate=WARN
logging.level.org.eclipse.jetty=WARN
#logging.level.org.springframework.security.saml2=TRACE
#logging.level.org.springframework.security=DEBUG
#logging.level.org.opensaml=DEBUG
#logging.level.stirling.software.SPDF.config.security: DEBUG
logging.level.com.zaxxer.hikari=WARN
spring.jpa.open-in-view=false
server.forward-headers-strategy=NATIVE
server.error.path=/error
server.error.whitelabel.enabled=false
server.error.include-stacktrace=always
server.error.include-exception=true
server.error.include-message=always
logging.level.org.springframework.web=DEBUG
logging.level.org.springframework=DEBUG
logging.level.org.springframework.security=DEBUG
spring.servlet.multipart.max-file-size=2000MB
spring.servlet.multipart.max-request-size=2000MB
server.servlet.session.tracking-modes=cookie
server.servlet.context-path=${SYSTEM_ROOTURIPATH:/}
spring.devtools.restart.enabled=true
spring.devtools.livereload.enabled=true
spring.devtools.restart.exclude=stirling.software.proprietary.security/**
spring.thymeleaf.encoding=UTF-8
spring.web.resources.mime-mappings.webmanifest=application/manifest+json
spring.mvc.async.request-timeout=${SYSTEM_CONNECTIONTIMEOUTMILLISECONDS:1200000}
management.endpoints.web.exposure.include=beans
spring.datasource.url=jdbc:h2:file:./configs/stirling-pdf-DB-2.3.232;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=PostgreSQL
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.h2.console.enabled=true
spring.jpa.hibernate.ddl-auto=update
server.servlet.session.timeout:30m
# Change the default URL path for OpenAPI JSON
springdoc.api-docs.path=/v1/api-docs
# Set the URL of the OpenAPI JSON for the Swagger UI
springdoc.swagger-ui.url=/v1/api-docs
springdoc.swagger-ui.path=/index.html
posthog.api.key=phc_fiR65u5j6qmXTYL56MNrLZSWqLaDW74OrZH0Insd2xq
posthog.host=https://eu.i.posthog.com