Skip to content

Commit 3e43f2d

Browse files
committed
fix(security): permit /api/health unauthenticated for k8s probes
Adds /api/health to the permitAll() block alongside /api/runtime-config so Kubernetes liveness/readiness probes can reach it without a session. Also adds the matching CSRF exemption to the ldap, ad, and oidc auth paths (local already had it). closes #124
1 parent d0de455 commit 3e43f2d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

git-proxy-java-dashboard/src/main/java/org/finos/gitproxy/dashboard/SecurityConfig.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
128128
: new String[] {"/api/**", "/login", "/logout"};
129129

130130
http.securityMatcher(protectedPaths)
131-
.authorizeHttpRequests(auth -> auth.requestMatchers("/api/runtime-config")
131+
.authorizeHttpRequests(auth -> auth.requestMatchers("/api/runtime-config", "/api/health")
132132
.permitAll()
133133
.requestMatchers(
134134
org.springframework.http.HttpMethod.POST,
@@ -260,6 +260,7 @@ private void configureLdapAuth(
260260
.csrf(csrf -> csrf.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
261261
.csrfTokenRequestHandler(new SpaCsrfTokenRequestHandler())
262262
.ignoringRequestMatchers("/login")
263+
.ignoringRequestMatchers("/api/health", "/api/")
263264
.ignoringRequestMatchers(req -> req.getHeader("X-Api-Key") != null));
264265

265266
if (!ldapCfg.getUserSearchFilter().isBlank()) {
@@ -327,6 +328,7 @@ private void configureAdAuth(
327328
.csrf(csrf -> csrf.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
328329
.csrfTokenRequestHandler(new SpaCsrfTokenRequestHandler())
329330
.ignoringRequestMatchers("/login")
331+
.ignoringRequestMatchers("/api/health", "/api/")
330332
.ignoringRequestMatchers(req -> req.getHeader("X-Api-Key") != null));
331333

332334
log.info("Active Directory authentication configured: domain={}, url={}", adCfg.getDomain(), adUrl);
@@ -414,6 +416,7 @@ private void configureOidcAuth(
414416
.csrf(csrf -> csrf.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
415417
.csrfTokenRequestHandler(new SpaCsrfTokenRequestHandler())
416418
.ignoringRequestMatchers("/login/oauth2/code/**")
419+
.ignoringRequestMatchers("/api/health", "/api/")
417420
.ignoringRequestMatchers(req -> req.getHeader("X-Api-Key") != null));
418421

419422
log.info(

0 commit comments

Comments
 (0)