Check DOCKER_ENABLE_SECURITY for UI (#1103)

When using `DOCKER_ENABLE_SECURITY=false`, the logout button and `Account Settings` are no longer displayed.
This commit is contained in:
Ludy 2024-04-21 22:16:39 +02:00 committed by GitHub
parent 5185fd13b8
commit 3189d9dda8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View file

@ -6,6 +6,7 @@ import java.nio.file.Paths;
import java.util.Properties; import java.util.Properties;
import org.springframework.beans.factory.annotation.Autowired; 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.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
@ -85,4 +86,10 @@ public class AppConfig {
} }
return "true".equalsIgnoreCase(installOps); return "true".equalsIgnoreCase(installOps);
} }
@ConditionalOnMissingClass("stirling.software.SPDF.config.security.SecurityConfiguration")
@Bean(name = "activSecurity")
public boolean missingActivSecurity() {
return false;
}
} }

View file

@ -166,4 +166,9 @@ public class SecurityConfiguration {
public PersistentTokenRepository persistentTokenRepository() { public PersistentTokenRepository persistentTokenRepository() {
return new JPATokenRepositoryImpl(); return new JPATokenRepositoryImpl();
} }
@Bean
public boolean activSecurity() {
return true;
}
} }

View file

@ -218,10 +218,10 @@
<input type="checkbox" class="form-check-input" id="cacheInputs" th:title="#{settings.cacheInputs.help}"> <input type="checkbox" class="form-check-input" id="cacheInputs" th:title="#{settings.cacheInputs.help}">
<label class="form-check-label" for="cacheInputs" th:text="#{settings.cacheInputs.name}"></label> <label class="form-check-label" for="cacheInputs" th:text="#{settings.cacheInputs.name}"></label>
</div> </div>
<a th:if="${@loginEnabled}" href="account" class="btn btn-sm btn-outline-primary" role="button" th:text="#{settings.accountSettings}" target="_blank">Account Settings</a> <a th:if="${@loginEnabled and @activSecurity}" href="account" class="btn btn-sm btn-outline-primary" role="button" th:text="#{settings.accountSettings}" target="_blank">Account Settings</a>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a th:if="${@loginEnabled}" class="btn btn-danger" role="button" th:text="#{settings.signOut}" href="logout">Sign Out</a> <a th:if="${@loginEnabled and @activSecurity}" class="btn btn-danger" role="button" th:text="#{settings.signOut}" href="logout">Sign Out</a>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" th:text="#{close}"></button> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal" th:text="#{close}"></button>
</div> </div>
</div> </div>