Springboot 3 + spring-boot-starter-actuator 3 + Basic Authentication
We are newbies for Springboot. Our requirement is any work service should have basic authentication but actuator/health. Here is our…
Springboot 3 + spring-boot-starter-actuator 3 + Basic Authentication
We are newbies for Springboot. Our requirement is any work service should have basic authentication but actuator/health. Here is our works:-
- spring.config.location (.yml)
spring:
security:
user:
name: admin
password: admin123
management:
web:
exposure:
include: health
- SpringSecurityConfig.java
@Configuration
@EnableWebSecurity
public class SpringSecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
.csrf(csrf -> csrf.disable())
.authorizeHttpRequests(
authorize -> authorize
.requestMatchers(EndpointRequest.to("health")).permitAll()
.anyRequest().authenticated()
)
.httpBasic(Customizer.withDefaults());
return http.build();
}
}ja
When we request to http://localhost:7001/actuator/health without any authentication. We get HTTP status 200 and {“status”: “UP”}.
When we request to http://localhost:7001/service1 without any authentication. We get HTTP status 401. But if we put basic authentication “admin:admin123”. The service responds HTTP 200 as we need.
We hope this story will guide you to set Springboot authentication.
Enjoy!
메타데이터
- post_id
- d84cccd5f384
- slug
- springboot-3-spring-boot-starter-actuator-3-basic-authentication-d84cccd5f384
- url
- https://medium.com/@paween-p/springboot-3-spring-boot-starter-actuator-3-basic-authentication-d84cccd5f384
- canonical_url
- https://medium.com/@paween-p/springboot-3-spring-boot-starter-actuator-3-basic-authentication-d84cccd5f384
- author_url
- https://medium.com/@paween-p
- status
- ok
- fetched_at
- 2026-06-29 01:02:39