The repository does not invent a production service identity. Until a deployment-owned + * authentication mechanism is selected and proven under issue #193, only health and info actuator + * endpoints are intentionally public and every configuration-resource request is denied. A future + * authenticated production profile must replace this reference-only posture through a separately + * reviewed security contract rather than weakening this default.
+ */ +@Configuration(proxyBeanMethods = false) +public class ConfigServerSecurityConfiguration { + + /** + * Builds the reference-only Config Server security chain. + * + * @param http Spring Security's servlet HTTP configuration builder + * @return the configured filter chain + * @throws Exception when Spring Security cannot build the filter chain + */ + @Bean + public SecurityFilterChain configServerSecurityFilterChain(HttpSecurity http) throws Exception { + http + .csrf(csrf -> csrf.disable()) + .httpBasic(httpBasic -> httpBasic.disable()) + .formLogin(formLogin -> formLogin.disable()) + .logout(logout -> logout.disable()) + .authorizeHttpRequests(authorize -> authorize + .requestMatchers( + "/actuator/health", + "/actuator/health/**", + "/actuator/info" + ).permitAll() + .anyRequest().denyAll()); + return http.build(); + } +} diff --git a/config-server/src/test/java/com/xtrmetl/config/ConfigServerInboundSecurityTest.java b/config-server/src/test/java/com/xtrmetl/config/ConfigServerInboundSecurityTest.java new file mode 100644 index 00000000..43db3ce1 --- /dev/null +++ b/config-server/src/test/java/com/xtrmetl/config/ConfigServerInboundSecurityTest.java @@ -0,0 +1,37 @@ +package com.xtrmetl.config; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Verifies the fail-closed inbound HTTP boundary for the reference-only Config Server profile. + */ +@SpringBootTest( + classes = ConfigServerApplication.class, + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = { + "spring.profiles.active=native", + "spring.cloud.config.server.native.search-locations=classpath:/", + "eureka.client.enabled=false" + } +) +class ConfigServerInboundSecurityTest { + + @Autowired + private TestRestTemplate restTemplate; + + @Test + void anonymousConfigurationReadIsDeniedWhileHealthRemainsPublic() { + ResponseEntity