From 3189d9dda899a3c8762a36df7285476cf10818a9 Mon Sep 17 00:00:00 2001 From: Ludy Date: Sun, 21 Apr 2024 22:16:39 +0200 Subject: [PATCH] Check `DOCKER_ENABLE_SECURITY` for UI (#1103) When using `DOCKER_ENABLE_SECURITY=false`, the logout button and `Account Settings` are no longer displayed. --- src/main/java/stirling/software/SPDF/config/AppConfig.java | 7 +++++++ .../SPDF/config/security/SecurityConfiguration.java | 5 +++++ src/main/resources/templates/fragments/navbar.html | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/config/AppConfig.java b/src/main/java/stirling/software/SPDF/config/AppConfig.java index fc5e9596..d239969f 100644 --- a/src/main/java/stirling/software/SPDF/config/AppConfig.java +++ b/src/main/java/stirling/software/SPDF/config/AppConfig.java @@ -6,6 +6,7 @@ import java.nio.file.Paths; import java.util.Properties; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; @@ -85,4 +86,10 @@ public class AppConfig { } return "true".equalsIgnoreCase(installOps); } + + @ConditionalOnMissingClass("stirling.software.SPDF.config.security.SecurityConfiguration") + @Bean(name = "activSecurity") + public boolean missingActivSecurity() { + return false; + } } diff --git a/src/main/java/stirling/software/SPDF/config/security/SecurityConfiguration.java b/src/main/java/stirling/software/SPDF/config/security/SecurityConfiguration.java index e9497f20..bbea5e96 100644 --- a/src/main/java/stirling/software/SPDF/config/security/SecurityConfiguration.java +++ b/src/main/java/stirling/software/SPDF/config/security/SecurityConfiguration.java @@ -166,4 +166,9 @@ public class SecurityConfiguration { public PersistentTokenRepository persistentTokenRepository() { return new JPATokenRepositoryImpl(); } + + @Bean + public boolean activSecurity() { + return true; + } } diff --git a/src/main/resources/templates/fragments/navbar.html b/src/main/resources/templates/fragments/navbar.html index 414ff51f..4d67edb6 100644 --- a/src/main/resources/templates/fragments/navbar.html +++ b/src/main/resources/templates/fragments/navbar.html @@ -218,10 +218,10 @@ - Account Settings + Account Settings