diff --git a/README.md b/README.md index 1137530..c767e43 100644 --- a/README.md +++ b/README.md @@ -51,3 +51,8 @@ - `DELETE /images/{id}` Delete my image - `GET /images/my` My uploaded images - `GET /images` Home / search images **_Public_** + + + +# Spring Boot Actuator +- `GET /actuator/health` \ No newline at end of file diff --git a/pom.xml b/pom.xml index 6a217a3..a639f7f 100644 --- a/pom.xml +++ b/pom.xml @@ -109,6 +109,12 @@ 2.0.3 + + + org.springframework.boot + spring-boot-starter-actuator + + diff --git a/src/main/java/dev/barboud/taglens/configuration/SecurityConfig.java b/src/main/java/dev/barboud/taglens/configuration/SecurityConfig.java index a7221c5..ebb3a05 100644 --- a/src/main/java/dev/barboud/taglens/configuration/SecurityConfig.java +++ b/src/main/java/dev/barboud/taglens/configuration/SecurityConfig.java @@ -22,6 +22,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .authorizeHttpRequests(auth -> auth .requestMatchers("/auth/login", "/auth/register").permitAll() // login & register: public .requestMatchers("/", "/*.html", "/*.css", "/*.js").permitAll() + .requestMatchers("/actuator/**").permitAll() .anyRequest().authenticated() // everything else: must be logged in ) .addFilterBefore(sessionAuthFilter, UsernamePasswordAuthenticationFilter.class); diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 144f678..9efc25e 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -1,2 +1,9 @@ logging.level.root=INFO -logging.level.org.springframework.jdbc.core=DEBUG \ No newline at end of file +logging.level.org.springframework.jdbc.core=DEBUG + + +# Expose endpoints (health and metrics) +management.endpoints.web.exposure.include=health,metrics + +# Show full health details (e.g., DB status, disk space) +management.endpoint.health.show-details=always \ No newline at end of file diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index fe863ef..bcd88c7 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -1 +1,11 @@ -logging.level.root=WARN \ No newline at end of file +logging.level.root=WARN + + +# Expose ONLY the health endpoint for hosting/load balancer health checks +management.endpoints.web.exposure.include=health + +# Show details only when authorized, or set to 'never' to prevent information leakage +management.endpoint.health.show-details=when-authorized + +# Optional: Run actuator on a separate management port for extra security (not publicly accessible) +# management.server.port=8081 \ No newline at end of file