This is an automated email from the ASF dual-hosted git repository. ilgrosso pushed a commit to branch 4_1_X in repository https://gitbox.apache.org/repos/asf/syncope.git
commit 81501a4f3126e58b9a1421de203503ec782a48da Author: Francesco Chicchiriccò <[email protected]> AuthorDate: Thu Sep 17 14:30:57 2026 +0200 [SYNCOPE-1996] Startup warning when not runnin in production mode --- .../spring/security/DefaultCredentialChecker.java | 8 ++--- .../core/starter/ProductionModeChecker.java | 42 ++++++++++++++++++++++ .../core/starter/SyncopeCoreApplication.java | 5 +++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/core/spring/src/main/java/org/apache/syncope/core/spring/security/DefaultCredentialChecker.java b/core/spring/src/main/java/org/apache/syncope/core/spring/security/DefaultCredentialChecker.java index c877848553..df72ccd74d 100644 --- a/core/spring/src/main/java/org/apache/syncope/core/spring/security/DefaultCredentialChecker.java +++ b/core/spring/src/main/java/org/apache/syncope/core/spring/security/DefaultCredentialChecker.java @@ -32,19 +32,19 @@ public class DefaultCredentialChecker { private static final Logger LOG = LoggerFactory.getLogger(DefaultCredentialChecker.class); private static final String DEFAULT_AES_KEY_ERROR_MESSAGE = - "The default AES key property is being used. " + "⚠ The default AES key property is being used. " + "This must be changed to avoid a security breach!"; private static final String DEFAULT_JWS_KEY_ERROR_MESSAGE = - "The default JWKS key property is being used. " + "⚠ The default JWKS key property is being used. " + "This must be changed to avoid a security breach!"; private static final String DEFAULT_ADMIN_PASSWORD_ERROR_MESSAGE = - "The default adminPassword property is being used. " + "⚠ The default adminPassword property is being used. " + "This must be changed to avoid a security breach!"; private static final String DEFAULT_ANON_KEY_ERROR_MESSAGE = - "The default anonymousKey property is being used. " + "⚠ The default anonymousKey property is being used. " + "This must be changed to avoid a security breach!"; private final boolean defaultAesKeyInUse; diff --git a/core/starter/src/main/java/org/apache/syncope/core/starter/ProductionModeChecker.java b/core/starter/src/main/java/org/apache/syncope/core/starter/ProductionModeChecker.java new file mode 100644 index 0000000000..d482cabfa5 --- /dev/null +++ b/core/starter/src/main/java/org/apache/syncope/core/starter/ProductionModeChecker.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.core.starter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.event.EventListener; + +public class ProductionModeChecker { + + protected static final Logger LOG = LoggerFactory.getLogger(ProductionModeChecker.class); + + @Value("${security.productionMode:true}") + protected boolean productionMode; + + @EventListener(ApplicationReadyEvent.class) + public void check() { + if (!productionMode) { + LOG.warn("*********************************************************"); + LOG.warn(" ⚠️ WARNING: Syncope Core is not running in Production Mode "); + LOG.warn("*********************************************************"); + } + } +} diff --git a/core/starter/src/main/java/org/apache/syncope/core/starter/SyncopeCoreApplication.java b/core/starter/src/main/java/org/apache/syncope/core/starter/SyncopeCoreApplication.java index 99e28cc6cb..5bc5ad7853 100644 --- a/core/starter/src/main/java/org/apache/syncope/core/starter/SyncopeCoreApplication.java +++ b/core/starter/src/main/java/org/apache/syncope/core/starter/SyncopeCoreApplication.java @@ -114,6 +114,11 @@ public class SyncopeCoreApplication extends SpringBootServletInitializer { return builder.properties(Map.of("spring.config.name", "core")).sources(SyncopeCoreApplication.class); } + @Bean + public ProductionModeChecker productionModeChecker() { + return new ProductionModeChecker(); + } + @ConditionalOnMissingBean @Bean public TaskExecutorUnloader taskExecutorUnloader(final ListableBeanFactory beanFactory) {
