mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-03 17:52:30 +02:00
Boolean to boolean
This commit is contained in:
parent
2a9f92d193
commit
f3df91e7d5
@ -61,7 +61,7 @@ public class AppConfig {
|
|||||||
|
|
||||||
@Bean(name = "loginEnabled")
|
@Bean(name = "loginEnabled")
|
||||||
public boolean loginEnabled() {
|
public boolean loginEnabled() {
|
||||||
return applicationProperties.getSecurity().getEnableLogin();
|
return applicationProperties.getSecurity().isEnableLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "appName")
|
@Bean(name = "appName")
|
||||||
@ -111,9 +111,7 @@ public class AppConfig {
|
|||||||
|
|
||||||
@Bean(name = "enableAlphaFunctionality")
|
@Bean(name = "enableAlphaFunctionality")
|
||||||
public boolean enableAlphaFunctionality() {
|
public boolean enableAlphaFunctionality() {
|
||||||
return applicationProperties.getSystem().getEnableAlphaFunctionality() != null
|
return applicationProperties.getSystem().isEnableAlphaFunctionality();
|
||||||
? applicationProperties.getSystem().getEnableAlphaFunctionality()
|
|
||||||
: false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "rateLimit")
|
@Bean(name = "rateLimit")
|
||||||
|
@ -110,8 +110,8 @@ public class ApplicationProperties {
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Security {
|
public static class Security {
|
||||||
private Boolean enableLogin = false;
|
private boolean enableLogin;
|
||||||
private Boolean csrfDisabled = false;
|
private boolean csrfDisabled;
|
||||||
private InitialLogin initialLogin = new InitialLogin();
|
private InitialLogin initialLogin = new InitialLogin();
|
||||||
private OAUTH2 oauth2 = new OAUTH2();
|
private OAUTH2 oauth2 = new OAUTH2();
|
||||||
private SAML2 saml2 = new SAML2();
|
private SAML2 saml2 = new SAML2();
|
||||||
@ -302,17 +302,17 @@ public class ApplicationProperties {
|
|||||||
@Data
|
@Data
|
||||||
public static class System {
|
public static class System {
|
||||||
private String defaultLocale;
|
private String defaultLocale;
|
||||||
private Boolean googlevisibility = false;
|
private boolean googlevisibility;
|
||||||
private boolean showUpdate;
|
private boolean showUpdate;
|
||||||
private Boolean showUpdateOnlyAdmin = false;
|
private boolean showUpdateOnlyAdmin;
|
||||||
private boolean customHTMLFiles;
|
private boolean customHTMLFiles;
|
||||||
private String tessdataDir;
|
private String tessdataDir;
|
||||||
private Boolean enableAlphaFunctionality = false;
|
private boolean enableAlphaFunctionality;
|
||||||
private Boolean enableAnalytics;
|
private Boolean enableAnalytics;
|
||||||
private Datasource datasource;
|
private Datasource datasource;
|
||||||
private Boolean disableSanitize = false;
|
private boolean disableSanitize;
|
||||||
private int maxDPI;
|
private int maxDPI;
|
||||||
private Boolean enableUrlToPDF = false;
|
private boolean enableUrlToPDF;
|
||||||
private Html html = new Html();
|
private Html html = new Html();
|
||||||
private CustomPaths customPaths = new CustomPaths();
|
private CustomPaths customPaths = new CustomPaths();
|
||||||
private String fileUploadLimit;
|
private String fileUploadLimit;
|
||||||
@ -458,7 +458,7 @@ public class ApplicationProperties {
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Metrics {
|
public static class Metrics {
|
||||||
private Boolean enabled = true;
|
private boolean enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@ -253,11 +253,11 @@ public class PostHogService {
|
|||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"security_enableLogin",
|
"security_enableLogin",
|
||||||
applicationProperties.getSecurity().getEnableLogin());
|
applicationProperties.getSecurity().isEnableLogin());
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"security_csrfDisabled",
|
"security_csrfDisabled",
|
||||||
applicationProperties.getSecurity().getCsrfDisabled());
|
applicationProperties.getSecurity().isCsrfDisabled());
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"security_loginAttemptCount",
|
"security_loginAttemptCount",
|
||||||
@ -302,13 +302,13 @@ public class PostHogService {
|
|||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"system_googlevisibility",
|
"system_googlevisibility",
|
||||||
applicationProperties.getSystem().getGooglevisibility());
|
applicationProperties.getSystem().isGooglevisibility());
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties, "system_showUpdate", applicationProperties.getSystem().isShowUpdate());
|
properties, "system_showUpdate", applicationProperties.getSystem().isShowUpdate());
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"system_showUpdateOnlyAdmin",
|
"system_showUpdateOnlyAdmin",
|
||||||
applicationProperties.getSystem().getShowUpdateOnlyAdmin());
|
applicationProperties.getSystem().isShowUpdateOnlyAdmin());
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"system_customHTMLFiles",
|
"system_customHTMLFiles",
|
||||||
@ -320,7 +320,7 @@ public class PostHogService {
|
|||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"system_enableAlphaFunctionality",
|
"system_enableAlphaFunctionality",
|
||||||
applicationProperties.getSystem().getEnableAlphaFunctionality());
|
applicationProperties.getSystem().isEnableAlphaFunctionality());
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties,
|
properties,
|
||||||
"system_enableAnalytics",
|
"system_enableAnalytics",
|
||||||
@ -337,7 +337,7 @@ public class PostHogService {
|
|||||||
|
|
||||||
// Capture Metrics properties
|
// Capture Metrics properties
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
properties, "metrics_enabled", applicationProperties.getMetrics().getEnabled());
|
properties, "metrics_enabled", applicationProperties.getMetrics().isEnabled());
|
||||||
|
|
||||||
// Capture EnterpriseEdition properties
|
// Capture EnterpriseEdition properties
|
||||||
addIfNotEmpty(
|
addIfNotEmpty(
|
||||||
|
@ -64,8 +64,7 @@ public class CustomHtmlSanitizer {
|
|||||||
.and(new HtmlPolicyBuilder().disallowElements("noscript").toFactory());
|
.and(new HtmlPolicyBuilder().disallowElements("noscript").toFactory());
|
||||||
|
|
||||||
public String sanitize(String html) {
|
public String sanitize(String html) {
|
||||||
boolean disableSanitize =
|
boolean disableSanitize = applicationProperties.getSystem().isDisableSanitize();
|
||||||
Boolean.TRUE.equals(applicationProperties.getSystem().getDisableSanitize());
|
|
||||||
return disableSanitize ? html : POLICY.sanitize(html);
|
return disableSanitize ? html : POLICY.sanitize(html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ class CustomHtmlSanitizerTest {
|
|||||||
when(mockSsrfProtectionService.isUrlAllowed(org.mockito.ArgumentMatchers.anyString()))
|
when(mockSsrfProtectionService.isUrlAllowed(org.mockito.ArgumentMatchers.anyString()))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
when(mockApplicationProperties.getSystem()).thenReturn(mockSystem);
|
when(mockApplicationProperties.getSystem()).thenReturn(mockSystem);
|
||||||
when(mockSystem.getDisableSanitize()).thenReturn(false); // Enable sanitization for tests
|
when(mockSystem.isDisableSanitize()).thenReturn(false); // Enable sanitization for tests
|
||||||
|
|
||||||
customHtmlSanitizer =
|
customHtmlSanitizer =
|
||||||
new CustomHtmlSanitizer(mockSsrfProtectionService, mockApplicationProperties);
|
new CustomHtmlSanitizer(mockSsrfProtectionService, mockApplicationProperties);
|
||||||
|
@ -52,7 +52,7 @@ class EmlToPdfTest {
|
|||||||
when(mockSsrfProtectionService.isUrlAllowed(org.mockito.ArgumentMatchers.anyString()))
|
when(mockSsrfProtectionService.isUrlAllowed(org.mockito.ArgumentMatchers.anyString()))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
when(mockApplicationProperties.getSystem()).thenReturn(mockSystem);
|
when(mockApplicationProperties.getSystem()).thenReturn(mockSystem);
|
||||||
when(mockSystem.getDisableSanitize()).thenReturn(false);
|
when(mockSystem.isDisableSanitize()).thenReturn(false);
|
||||||
|
|
||||||
customHtmlSanitizer =
|
customHtmlSanitizer =
|
||||||
new CustomHtmlSanitizer(mockSsrfProtectionService, mockApplicationProperties);
|
new CustomHtmlSanitizer(mockSsrfProtectionService, mockApplicationProperties);
|
||||||
|
@ -31,7 +31,7 @@ public class FileToPdfTest {
|
|||||||
when(mockSsrfProtectionService.isUrlAllowed(org.mockito.ArgumentMatchers.anyString()))
|
when(mockSsrfProtectionService.isUrlAllowed(org.mockito.ArgumentMatchers.anyString()))
|
||||||
.thenReturn(true);
|
.thenReturn(true);
|
||||||
when(mockApplicationProperties.getSystem()).thenReturn(mockSystem);
|
when(mockApplicationProperties.getSystem()).thenReturn(mockSystem);
|
||||||
when(mockSystem.getDisableSanitize()).thenReturn(false);
|
when(mockSystem.isDisableSanitize()).thenReturn(false);
|
||||||
|
|
||||||
customHtmlSanitizer =
|
customHtmlSanitizer =
|
||||||
new CustomHtmlSanitizer(mockSsrfProtectionService, mockApplicationProperties);
|
new CustomHtmlSanitizer(mockSsrfProtectionService, mockApplicationProperties);
|
||||||
|
@ -464,7 +464,7 @@ public class EndpointConfiguration {
|
|||||||
disableGroup("enterprise");
|
disableGroup("enterprise");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!applicationProperties.getSystem().getEnableUrlToPDF()) {
|
if (!applicationProperties.getSystem().isEnableUrlToPDF()) {
|
||||||
disableEndpoint("url-to-pdf");
|
disableEndpoint("url-to-pdf");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class InitialSetup {
|
|||||||
public void initEnableCSRFSecurity() throws IOException {
|
public void initEnableCSRFSecurity() throws IOException {
|
||||||
if (GeneralUtils.isVersionHigher(
|
if (GeneralUtils.isVersionHigher(
|
||||||
"0.46.0", applicationProperties.getAutomaticallyGenerated().getAppVersion())) {
|
"0.46.0", applicationProperties.getAutomaticallyGenerated().getAppVersion())) {
|
||||||
Boolean csrf = applicationProperties.getSecurity().getCsrfDisabled();
|
boolean csrf = applicationProperties.getSecurity().isCsrfDisabled();
|
||||||
if (!csrf) {
|
if (!csrf) {
|
||||||
GeneralUtils.saveKeyToSettings("security.csrfDisabled", false);
|
GeneralUtils.saveKeyToSettings("security.csrfDisabled", false);
|
||||||
GeneralUtils.saveKeyToSettings("system.enableAnalytics", true);
|
GeneralUtils.saveKeyToSettings("system.enableAnalytics", true);
|
||||||
|
@ -50,7 +50,7 @@ public class OpenApiConfig {
|
|||||||
.url("https://www.stirlingpdf.com")
|
.url("https://www.stirlingpdf.com")
|
||||||
.email("contact@stirlingpdf.com"))
|
.email("contact@stirlingpdf.com"))
|
||||||
.description(DEFAULT_DESCRIPTION);
|
.description(DEFAULT_DESCRIPTION);
|
||||||
if (!applicationProperties.getSecurity().getEnableLogin()) {
|
if (!applicationProperties.getSecurity().isEnableLogin()) {
|
||||||
return new OpenAPI().components(new Components()).info(info);
|
return new OpenAPI().components(new Components()).info(info);
|
||||||
} else {
|
} else {
|
||||||
SecurityScheme apiKeyScheme =
|
SecurityScheme apiKeyScheme =
|
||||||
|
@ -50,7 +50,7 @@ public class ConvertWebsiteToPDF {
|
|||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
String URL = request.getUrlInput();
|
String URL = request.getUrlInput();
|
||||||
|
|
||||||
if (!applicationProperties.getSystem().getEnableUrlToPDF()) {
|
if (!applicationProperties.getSystem().isEnableUrlToPDF()) {
|
||||||
throw ExceptionUtils.createIllegalArgumentException(
|
throw ExceptionUtils.createIllegalArgumentException(
|
||||||
"error.endpointDisabled", "This endpoint has been disabled by the admin");
|
"error.endpointDisabled", "This endpoint has been disabled by the admin");
|
||||||
}
|
}
|
||||||
|
@ -84,8 +84,8 @@ public class HomeWebController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Hidden
|
@Hidden
|
||||||
public String getRobotsTxt() {
|
public String getRobotsTxt() {
|
||||||
Boolean allowGoogle = applicationProperties.getSystem().getGooglevisibility();
|
boolean allowGoogle = applicationProperties.getSystem().isGooglevisibility();
|
||||||
if (Boolean.TRUE.equals(allowGoogle)) {
|
if (allowGoogle) {
|
||||||
return "User-agent: Googlebot\nAllow: /\n\nUser-agent: *\nAllow: /";
|
return "User-agent: Googlebot\nAllow: /\n\nUser-agent: *\nAllow: /";
|
||||||
} else {
|
} else {
|
||||||
return "User-agent: Googlebot\nDisallow: /\n\nUser-agent: *\nDisallow: /";
|
return "User-agent: Googlebot\nDisallow: /\n\nUser-agent: *\nDisallow: /";
|
||||||
|
@ -40,7 +40,7 @@ public class MetricsController {
|
|||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
Boolean metricsEnabled = applicationProperties.getMetrics().getEnabled();
|
Boolean metricsEnabled = applicationProperties.getMetrics().isEnabled();
|
||||||
if (metricsEnabled == null) metricsEnabled = true;
|
if (metricsEnabled == null) metricsEnabled = true;
|
||||||
this.metricsEnabled = metricsEnabled;
|
this.metricsEnabled = metricsEnabled;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ public class AccountWebController {
|
|||||||
SAML2 saml2 = securityProps.getSaml2();
|
SAML2 saml2 = securityProps.getSaml2();
|
||||||
|
|
||||||
if (securityProps.isSaml2Active()
|
if (securityProps.isSaml2Active()
|
||||||
&& applicationProperties.getSystem().getEnableAlphaFunctionality()
|
&& applicationProperties.getSystem().isEnableAlphaFunctionality()
|
||||||
&& applicationProperties.getPremium().isEnabled()) {
|
&& applicationProperties.getPremium().isEnabled()) {
|
||||||
String samlIdp = saml2.getProvider();
|
String samlIdp = saml2.getProvider();
|
||||||
String saml2AuthenticationPath = "/saml2/authenticate/" + saml2.getRegistrationId();
|
String saml2AuthenticationPath = "/saml2/authenticate/" + saml2.getRegistrationId();
|
||||||
@ -240,7 +240,7 @@ public class AccountWebController {
|
|||||||
|
|
||||||
// Also check if user is part of the Internal team
|
// Also check if user is part of the Internal team
|
||||||
if (user.getTeam() != null
|
if (user.getTeam() != null
|
||||||
&& user.getTeam().getName().equals(TeamService.INTERNAL_TEAM_NAME)) {
|
&& TeamService.INTERNAL_TEAM_NAME.equals(user.getTeam().getName())) {
|
||||||
shouldRemove = true;
|
shouldRemove = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,11 +359,9 @@ public class AccountWebController {
|
|||||||
teamRepository.findAll().stream()
|
teamRepository.findAll().stream()
|
||||||
.filter(
|
.filter(
|
||||||
team ->
|
team ->
|
||||||
!team.getName()
|
!stirling.software.proprietary.security.service.TeamService
|
||||||
.equals(
|
.INTERNAL_TEAM_NAME
|
||||||
stirling.software.proprietary.security
|
.equals(team.getName()))
|
||||||
.service.TeamService
|
|
||||||
.INTERNAL_TEAM_NAME))
|
|
||||||
.toList();
|
.toList();
|
||||||
model.addAttribute("teams", allTeams);
|
model.addAttribute("teams", allTeams);
|
||||||
|
|
||||||
|
@ -115,14 +115,14 @@ public class SecurityConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||||
if (applicationProperties.getSecurity().getCsrfDisabled() || !loginEnabledValue) {
|
if (applicationProperties.getSecurity().isCsrfDisabled() || !loginEnabledValue) {
|
||||||
http.csrf(csrf -> csrf.disable());
|
http.csrf(csrf -> csrf.disable());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loginEnabledValue) {
|
if (loginEnabledValue) {
|
||||||
http.addFilterBefore(
|
http.addFilterBefore(
|
||||||
userAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
userAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
|
||||||
if (!applicationProperties.getSecurity().getCsrfDisabled()) {
|
if (!applicationProperties.getSecurity().isCsrfDisabled()) {
|
||||||
CookieCsrfTokenRepository cookieRepo =
|
CookieCsrfTokenRepository cookieRepo =
|
||||||
CookieCsrfTokenRepository.withHttpOnlyFalse();
|
CookieCsrfTokenRepository.withHttpOnlyFalse();
|
||||||
CsrfTokenRequestAttributeHandler requestHandler =
|
CsrfTokenRequestAttributeHandler requestHandler =
|
||||||
|
@ -27,7 +27,7 @@ class AppUpdateAuthService implements ShowAdminInterface {
|
|||||||
if (!showUpdate) {
|
if (!showUpdate) {
|
||||||
return showUpdate;
|
return showUpdate;
|
||||||
}
|
}
|
||||||
boolean showUpdateOnlyAdmin = applicationProperties.getSystem().getShowUpdateOnlyAdmin();
|
boolean showUpdateOnlyAdmin = applicationProperties.getSystem().isShowUpdateOnlyAdmin();
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (authentication == null || !authentication.isAuthenticated()) {
|
if (authentication == null || !authentication.isAuthenticated()) {
|
||||||
return !showUpdateOnlyAdmin;
|
return !showUpdateOnlyAdmin;
|
||||||
|
Loading…
Reference in New Issue
Block a user