Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78df38b600 | ||
|
|
63550e0c7d | ||
|
|
a2091b7851 | ||
|
|
43137cde83 | ||
|
|
9ea2c94912 | ||
|
|
ad33679c2b | ||
|
|
c390f21114 | ||
|
|
b03ecef121 | ||
|
|
3d9d2621fa | ||
|
|
9c84e1eed4 | ||
|
|
e424af1a31 | ||
|
|
71d416ce90 | ||
|
|
91cdd20b3f | ||
|
|
235e68fa2b | ||
|
|
3279b28a76 | ||
|
|
d95abcea95 | ||
|
|
a73636a597 |
@@ -37,10 +37,6 @@ public class AppConfig {
|
|||||||
|
|
||||||
private final ApplicationProperties applicationProperties;
|
private final ApplicationProperties applicationProperties;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Value("${baseUrl:http://localhost}")
|
|
||||||
private String baseUrl;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Value("${server.servlet.context-path:/}")
|
@Value("${server.servlet.context-path:/}")
|
||||||
private String contextPath;
|
private String contextPath;
|
||||||
@@ -49,6 +45,17 @@ public class AppConfig {
|
|||||||
@Value("${server.port:8080}")
|
@Value("${server.port:8080}")
|
||||||
private String serverPort;
|
private String serverPort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the backend URL from system configuration. Falls back to http://localhost if not
|
||||||
|
* configured.
|
||||||
|
*
|
||||||
|
* @return The backend base URL for SAML/OAuth/API callbacks
|
||||||
|
*/
|
||||||
|
public String getBackendUrl() {
|
||||||
|
String backendUrl = applicationProperties.getSystem().getBackendUrl();
|
||||||
|
return (backendUrl != null && !backendUrl.isBlank()) ? backendUrl : "http://localhost";
|
||||||
|
}
|
||||||
|
|
||||||
@Value("${v2}")
|
@Value("${v2}")
|
||||||
public boolean v2Enabled;
|
public boolean v2Enabled;
|
||||||
|
|
||||||
|
|||||||
@@ -138,13 +138,13 @@ public class SPDFApplication {
|
|||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
String baseUrl = appConfig.getBaseUrl();
|
String backendUrl = appConfig.getBackendUrl();
|
||||||
String contextPath = appConfig.getContextPath();
|
String contextPath = appConfig.getContextPath();
|
||||||
String serverPort = appConfig.getServerPort();
|
String serverPort = appConfig.getServerPort();
|
||||||
baseUrlStatic = baseUrl;
|
baseUrlStatic = backendUrl;
|
||||||
contextPathStatic = contextPath;
|
contextPathStatic = contextPath;
|
||||||
serverPortStatic = serverPort;
|
serverPortStatic = serverPort;
|
||||||
String url = baseUrl + ":" + getStaticPort() + contextPath;
|
String url = backendUrl + ":" + getStaticPort() + contextPath;
|
||||||
|
|
||||||
// Log Tauri mode information
|
// Log Tauri mode information
|
||||||
if (Boolean.parseBoolean(System.getProperty("STIRLING_PDF_TAURI_MODE", "false"))) {
|
if (Boolean.parseBoolean(System.getProperty("STIRLING_PDF_TAURI_MODE", "false"))) {
|
||||||
|
|||||||
+2
-1
@@ -66,7 +66,8 @@ public class ConfigController {
|
|||||||
AppConfig appConfig = applicationContext.getBean(AppConfig.class);
|
AppConfig appConfig = applicationContext.getBean(AppConfig.class);
|
||||||
|
|
||||||
// Extract key configuration values from AppConfig
|
// Extract key configuration values from AppConfig
|
||||||
configData.put("baseUrl", appConfig.getBaseUrl());
|
// Note: Frontend expects "baseUrl" field name for compatibility
|
||||||
|
configData.put("baseUrl", appConfig.getBackendUrl());
|
||||||
configData.put("contextPath", appConfig.getContextPath());
|
configData.put("contextPath", appConfig.getContextPath());
|
||||||
configData.put("serverPort", appConfig.getServerPort());
|
configData.put("serverPort", appConfig.getServerPort());
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -198,7 +198,7 @@ public class CustomLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler {
|
|||||||
private SamlClient getSamlClient(
|
private SamlClient getSamlClient(
|
||||||
String registrationId, SAML2 samlConf, List<X509Certificate> certificates)
|
String registrationId, SAML2 samlConf, List<X509Certificate> certificates)
|
||||||
throws SamlException {
|
throws SamlException {
|
||||||
String serverUrl = appConfig.getBaseUrl() + ":" + appConfig.getServerPort();
|
String serverUrl = appConfig.getBackendUrl() + ":" + appConfig.getServerPort();
|
||||||
|
|
||||||
String relyingPartyIdentifier =
|
String relyingPartyIdentifier =
|
||||||
serverUrl + "/saml2/service-provider-metadata/" + registrationId;
|
serverUrl + "/saml2/service-provider-metadata/" + registrationId;
|
||||||
|
|||||||
+2
-1
@@ -344,7 +344,8 @@ public class SecurityConfiguration {
|
|||||||
log.error("Error configuring SAML 2 login", e);
|
log.error("Error configuring SAML 2 login", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
.saml2Metadata(metadata -> {});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.debug("Login is not enabled.");
|
log.debug("Login is not enabled.");
|
||||||
|
|||||||
+20
-5
@@ -102,16 +102,31 @@ public class Saml2Configuration {
|
|||||||
log.error("Failed to load SAML2 SP credentials: {}", e.getMessage(), e);
|
log.error("Failed to load SAML2 SP credentials: {}", e.getMessage(), e);
|
||||||
throw new IllegalStateException("Failed to load SAML2 SP credentials", e);
|
throw new IllegalStateException("Failed to load SAML2 SP credentials", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get backend URL from configuration (for SAML endpoints)
|
||||||
|
String backendUrl = applicationProperties.getSystem().getBackendUrl();
|
||||||
|
if (backendUrl == null || backendUrl.isBlank()) {
|
||||||
|
backendUrl = "{baseUrl}"; // Fallback to Spring's auto-resolution
|
||||||
|
log.warn(
|
||||||
|
"system.backendUrl not configured - SAML metadata will use request-based URLs. Set system.backendUrl for production use.");
|
||||||
|
} else {
|
||||||
|
log.info("Using configured backend URL for SAML: {}", backendUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
String entityId =
|
||||||
|
backendUrl + "/saml2/service-provider-metadata/" + samlConf.getRegistrationId();
|
||||||
|
String acsLocation = backendUrl + "/login/saml2/sso/{registrationId}";
|
||||||
|
String sloResponseLocation = backendUrl + "/login";
|
||||||
|
|
||||||
RelyingPartyRegistration rp =
|
RelyingPartyRegistration rp =
|
||||||
RelyingPartyRegistration.withRegistrationId(samlConf.getRegistrationId())
|
RelyingPartyRegistration.withRegistrationId(samlConf.getRegistrationId())
|
||||||
.signingX509Credentials(c -> c.add(signingCredential))
|
.signingX509Credentials(c -> c.add(signingCredential))
|
||||||
.entityId(samlConf.getIdpIssuer())
|
.entityId(entityId)
|
||||||
.singleLogoutServiceBinding(Saml2MessageBinding.POST)
|
.singleLogoutServiceBinding(Saml2MessageBinding.POST)
|
||||||
.singleLogoutServiceLocation(samlConf.getIdpSingleLogoutUrl())
|
.singleLogoutServiceLocation(samlConf.getIdpSingleLogoutUrl())
|
||||||
.singleLogoutServiceResponseLocation("{baseUrl}/login")
|
.singleLogoutServiceResponseLocation(sloResponseLocation)
|
||||||
.assertionConsumerServiceBinding(Saml2MessageBinding.POST)
|
.assertionConsumerServiceBinding(Saml2MessageBinding.POST)
|
||||||
.assertionConsumerServiceLocation(
|
.assertionConsumerServiceLocation(acsLocation)
|
||||||
"{baseUrl}/login/saml2/sso/{registrationId}")
|
|
||||||
.authnRequestsSigned(true)
|
.authnRequestsSigned(true)
|
||||||
.assertingPartyMetadata(
|
.assertingPartyMetadata(
|
||||||
metadata ->
|
metadata ->
|
||||||
@@ -127,7 +142,7 @@ public class Saml2Configuration {
|
|||||||
.singleLogoutServiceLocation(
|
.singleLogoutServiceLocation(
|
||||||
samlConf.getIdpSingleLogoutUrl())
|
samlConf.getIdpSingleLogoutUrl())
|
||||||
.singleLogoutServiceResponseLocation(
|
.singleLogoutServiceResponseLocation(
|
||||||
"{baseUrl}/login")
|
sloResponseLocation)
|
||||||
.wantAuthnRequestsSigned(true))
|
.wantAuthnRequestsSigned(true))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -51,7 +51,8 @@ class UserLicenseSettingsServiceTest {
|
|||||||
|
|
||||||
when(applicationProperties.getPremium()).thenReturn(premium);
|
when(applicationProperties.getPremium()).thenReturn(premium);
|
||||||
when(applicationProperties.getAutomaticallyGenerated()).thenReturn(automaticallyGenerated);
|
when(applicationProperties.getAutomaticallyGenerated()).thenReturn(automaticallyGenerated);
|
||||||
when(automaticallyGenerated.getIsNewServer()).thenReturn(false); // Default: not a new server
|
when(automaticallyGenerated.getIsNewServer())
|
||||||
|
.thenReturn(false); // Default: not a new server
|
||||||
when(settingsRepository.findSettings()).thenReturn(Optional.of(mockSettings));
|
when(settingsRepository.findSettings()).thenReturn(Optional.of(mockSettings));
|
||||||
when(userService.getTotalUsersCount()).thenReturn(80L);
|
when(userService.getTotalUsersCount()).thenReturn(80L);
|
||||||
when(settingsRepository.save(any(UserLicenseSettings.class)))
|
when(settingsRepository.save(any(UserLicenseSettings.class)))
|
||||||
|
|||||||
Reference in New Issue
Block a user