Skip to content

Commit 3c8a8a4

Browse files
committed
Allow configuring insecure access to K8s probes
1 parent c94b5ca commit 3c8a8a4

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.box.l10n.mojito.security;
2+
3+
import org.springframework.boot.context.properties.ConfigurationProperties;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
/**
7+
* Configures insecure access to Kubernetes probes.
8+
*
9+
* @author wadimw
10+
*/
11+
@Configuration
12+
@ConfigurationProperties("l10n.actuator.health")
13+
public class ActuatorHealthConfig {
14+
15+
boolean allowInsecureKubernetesProbes = false;
16+
17+
public boolean getAllowInsecureKubernetesProbes() {
18+
return allowInsecureKubernetesProbes;
19+
}
20+
21+
public void setAllowInsecureKubernetesProbes(boolean allowInsecureKubernetesProbes) {
22+
this.allowInsecureKubernetesProbes = allowInsecureKubernetesProbes;
23+
}
24+
}

webapp/src/main/java/com/box/l10n/mojito/security/WebSecurityConfig.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public class WebSecurityConfig {
5858

5959
@Autowired ActuatorHealthLegacyConfig actuatorHealthLegacyConfig;
6060

61+
@Autowired ActuatorHealthConfig actuatorHealthConfig;
62+
6163
@Autowired UserDetailsContextMapperImpl userDetailsContextMapperImpl;
6264

6365
@Autowired UserService userService;
@@ -217,8 +219,13 @@ public SecurityFilterChain configure(HttpSecurity http) throws Exception {
217219
http.csrf()
218220
.ignoringRequestMatchers("/actuator/shutdown", "/actuator/loggers/**", "/api/rotation");
219221

220-
setAuthorizationRequests(
221-
http, getHealthcheckPatterns(actuatorHealthLegacyConfig.isForwarding()));
222+
List<String> extraPermitAllPatterns =
223+
new ArrayList<>(getHealthcheckPatterns(actuatorHealthLegacyConfig.isForwarding()));
224+
if (actuatorHealthConfig.getAllowInsecureKubernetesProbes()) {
225+
extraPermitAllPatterns.add("/actuator/health/liveness");
226+
extraPermitAllPatterns.add("/actuator/health/readiness");
227+
}
228+
setAuthorizationRequests(http, extraPermitAllPatterns);
222229

223230
logger.debug("For APIs, we don't redirect to login page. Instead we return a 401");
224231
http.exceptionHandling()

0 commit comments

Comments
 (0)