Add capability to disable Environment post processing for Security based on System property.
This commit is contained in:
@@ -65,6 +65,9 @@ import org.springframework.data.gemfire.config.annotation.support.AutoConfigured
|
||||
@SuppressWarnings("unused")
|
||||
public class SecurityAutoConfiguration {
|
||||
|
||||
public static final String SECURITY_CLOUD_ENVIRONMENT_POST_PROCESSOR_DISABLED_PROPERTY =
|
||||
"spring.boot.data.geode.security.auth.environment.post-processor.disabled";
|
||||
|
||||
private static final String CLOUD_CACHE_PROPERTY_SOURCE_NAME = "cloudcache-security";
|
||||
|
||||
private static final String MANAGEMENT_HTTP_HOST_PROPERTY = "spring.data.gemfire.management.http.host";
|
||||
@@ -87,6 +90,7 @@ public class SecurityAutoConfiguration {
|
||||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
|
||||
|
||||
Optional.of(environment)
|
||||
.filter(this::isEnabled)
|
||||
.filter(this::isCloudFoundryEnvironment)
|
||||
.ifPresent(env -> {
|
||||
|
||||
@@ -109,6 +113,14 @@ public class SecurityAutoConfiguration {
|
||||
return Optional.ofNullable(environment).filter(CloudPlatform.CLOUD_FOUNDRY::isActive).isPresent();
|
||||
}
|
||||
|
||||
private boolean isDisabled(Environment environment) {
|
||||
return Boolean.getBoolean(SECURITY_CLOUD_ENVIRONMENT_POST_PROCESSOR_DISABLED_PROPERTY);
|
||||
}
|
||||
|
||||
private boolean isEnabled(Environment environment) {
|
||||
return !isDisabled(environment);
|
||||
}
|
||||
|
||||
private boolean isSecurityPropertiesSet(Environment environment) {
|
||||
return environment.containsProperty(SECURITY_USERNAME_PROPERTY)
|
||||
&& environment.containsProperty(SECURITY_PASSWORD_PROPERTY);
|
||||
|
||||
Reference in New Issue
Block a user