Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
fix actuator security config
Browse files Browse the repository at this point in the history
  • Loading branch information
ubhaller committed Oct 12, 2021
1 parent 40c1115 commit 91da0a2
Showing 1 changed file with 3 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
import org.springframework.boot.actuate.info.InfoEndpoint;
import org.springframework.boot.actuate.logging.LoggersEndpoint;
import org.springframework.boot.actuate.metrics.export.prometheus.PrometheusScrapeEndpoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
Expand All @@ -38,53 +36,17 @@
public class ActuatorSecurity extends WebSecurityConfigurerAdapter {

private static final String PROMETHEUS_ROLE = "PROMETHEUS";
@Autowired Environment environment;

@Value("${ws.monitor.prometheus.user}")
private String user;

// region Actuator Passwords
// ----------------------------------------------------------------------------------------------------------------------------------
@Bean
@Profile("cloud-dev")
ActuatorSecurityConfig passwordCloudDev() {
return new ActuatorSecurityConfig(
user,
environment.getProperty("vcap.services.ha_prometheus_dev.credentials.password"));
}

@Bean
@Profile("cloud-test")
ActuatorSecurityConfig passwordCloudTest() {
return new ActuatorSecurityConfig(
user,
environment.getProperty("vcap.services.ha_prometheus_test.credentials.password"));
}

@Bean
@Profile("cloud-abn")
ActuatorSecurityConfig passwordCloudAbn() {
return new ActuatorSecurityConfig(
user,
environment.getProperty("vcap.services.ha_prometheus_abn.credentials.password"));
}

@Bean
@Profile("cloud-prod")
ActuatorSecurityConfig passwordProdAbn() {
return new ActuatorSecurityConfig(
user,
environment.getProperty("vcap.services.ha_prometheus_prod.credentials.password"));
}
@Value("${ws.monitor.prometheus.password}")
private String password;

@Bean
@ConditionalOnMissingBean
ActuatorSecurityConfig passwordDefault() {
return new ActuatorSecurityConfig(
user, environment.getProperty("ws.monitor.prometheus.password"));
return new ActuatorSecurityConfig(user, password);
}
// ----------------------------------------------------------------------------------------------------------------------------------
// endregion

@Override
protected void configure(HttpSecurity http) throws Exception {
Expand Down

0 comments on commit 91da0a2

Please sign in to comment.