From 35f822720665d2a5b352138b7517c5b27bc306fe Mon Sep 17 00:00:00 2001 From: y72wvh Date: Mon, 11 Sep 2023 11:22:28 +0200 Subject: [PATCH 1/3] feat: add healthcheck --- pom.xml | 2 +- .../constants/Constants.java | 2 ++ .../controller/HealthcheckController.java | 20 +++++++++++++++++++ .../heathcheck/dto/HealthcheckDto.java | 9 +++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/main/java/fr/insee/survey/datacollectionmanagement/heathcheck/controller/HealthcheckController.java create mode 100644 src/main/java/fr/insee/survey/datacollectionmanagement/heathcheck/dto/HealthcheckDto.java diff --git a/pom.xml b/pom.xml index 934776fd..fdb44c00 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ fr.insee.survey platine-management - 1.0.21-rc + 1.0.22-rc platine-management REST API for communication between DB and Platine-Management UI and Platine-My-Surveys UI diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/constants/Constants.java b/src/main/java/fr/insee/survey/datacollectionmanagement/constants/Constants.java index 19e49cda..fa26bd0a 100644 --- a/src/main/java/fr/insee/survey/datacollectionmanagement/constants/Constants.java +++ b/src/main/java/fr/insee/survey/datacollectionmanagement/constants/Constants.java @@ -96,4 +96,6 @@ private Constants() { public static final String INTERVIEWER = "interviewer"; public static final String REVIEWER = "reviewer"; + public static final String API_HEALTHCHECK = "/api/healthcheck"; + } \ No newline at end of file diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/heathcheck/controller/HealthcheckController.java b/src/main/java/fr/insee/survey/datacollectionmanagement/heathcheck/controller/HealthcheckController.java new file mode 100644 index 00000000..0629ff94 --- /dev/null +++ b/src/main/java/fr/insee/survey/datacollectionmanagement/heathcheck/controller/HealthcheckController.java @@ -0,0 +1,20 @@ +package fr.insee.survey.datacollectionmanagement.heathcheck.controller; + +import fr.insee.survey.datacollectionmanagement.constants.Constants; +import fr.insee.survey.datacollectionmanagement.heathcheck.dto.HealthcheckDto; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Tag(name = "8 - Heathckeck", description = "healthckeck") +public class HealthcheckController { + + @GetMapping(path = Constants.API_HEALTHCHECK, produces = "application/json") + public ResponseEntity healtcheck() { + HealthcheckDto dto = new HealthcheckDto(); + dto.setStatus("OK"); + return ResponseEntity.ok().body(dto); + } +} diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/heathcheck/dto/HealthcheckDto.java b/src/main/java/fr/insee/survey/datacollectionmanagement/heathcheck/dto/HealthcheckDto.java new file mode 100644 index 00000000..237f679f --- /dev/null +++ b/src/main/java/fr/insee/survey/datacollectionmanagement/heathcheck/dto/HealthcheckDto.java @@ -0,0 +1,9 @@ +package fr.insee.survey.datacollectionmanagement.heathcheck.dto; + +import lombok.Data; + +@Data +public class HealthcheckDto { + + private String status; +} From 0e9d62c94bf8c4f666eb43c459efaf3b70e4b802 Mon Sep 17 00:00:00 2001 From: y72wvh Date: Mon, 11 Sep 2023 11:33:31 +0200 Subject: [PATCH 2/3] Update HealthcheckController.java --- .../heathcheck/controller/HealthcheckController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/heathcheck/controller/HealthcheckController.java b/src/main/java/fr/insee/survey/datacollectionmanagement/heathcheck/controller/HealthcheckController.java index 0629ff94..5cdc7de5 100644 --- a/src/main/java/fr/insee/survey/datacollectionmanagement/heathcheck/controller/HealthcheckController.java +++ b/src/main/java/fr/insee/survey/datacollectionmanagement/heathcheck/controller/HealthcheckController.java @@ -8,11 +8,11 @@ import org.springframework.web.bind.annotation.RestController; @RestController -@Tag(name = "8 - Heathckeck", description = "healthckeck") +@Tag(name = "8 - Healthcheck", description = "healthcheck") public class HealthcheckController { @GetMapping(path = Constants.API_HEALTHCHECK, produces = "application/json") - public ResponseEntity healtcheck() { + public ResponseEntity healthcheck() { HealthcheckDto dto = new HealthcheckDto(); dto.setStatus("OK"); return ResponseEntity.ok().body(dto); From da891a8c50d997361b1fe99f10adf0181f130faa Mon Sep 17 00:00:00 2001 From: y72wvh Date: Mon, 11 Sep 2023 11:46:41 +0200 Subject: [PATCH 3/3] feat: change security url --- .../config/auth/security/DefaultSecurityContext.java | 3 ++- .../config/auth/security/OpenIDConnectSecurityContext.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/config/auth/security/DefaultSecurityContext.java b/src/main/java/fr/insee/survey/datacollectionmanagement/config/auth/security/DefaultSecurityContext.java index c89aa49f..c257101c 100644 --- a/src/main/java/fr/insee/survey/datacollectionmanagement/config/auth/security/DefaultSecurityContext.java +++ b/src/main/java/fr/insee/survey/datacollectionmanagement/config/auth/security/DefaultSecurityContext.java @@ -2,6 +2,7 @@ import static org.springframework.security.config.Customizer.withDefaults; +import fr.insee.survey.datacollectionmanagement.constants.Constants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; @@ -33,7 +34,7 @@ protected SecurityFilterChain configure(HttpSecurity http) throws Exception { .authorizeRequests() .antMatchers("/csrf", "/", "/webjars/**", "/swagger-resources/**").permitAll() .antMatchers("/environnement").permitAll()// PublicResources - .antMatchers("/healthcheck").permitAll() + .antMatchers(Constants.API_HEALTHCHECK).permitAll() .antMatchers("/actuator/**").permitAll() .antMatchers("/swagger-ui/*").permitAll() .antMatchers("/v3/api-docs/swagger-config", "/v3/api-docs").permitAll() diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/config/auth/security/OpenIDConnectSecurityContext.java b/src/main/java/fr/insee/survey/datacollectionmanagement/config/auth/security/OpenIDConnectSecurityContext.java index ae285d9a..d6463477 100644 --- a/src/main/java/fr/insee/survey/datacollectionmanagement/config/auth/security/OpenIDConnectSecurityContext.java +++ b/src/main/java/fr/insee/survey/datacollectionmanagement/config/auth/security/OpenIDConnectSecurityContext.java @@ -4,6 +4,7 @@ import java.util.List; +import fr.insee.survey.datacollectionmanagement.constants.Constants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; @@ -39,7 +40,7 @@ protected SecurityFilterChain configure(HttpSecurity http) throws Exception { .authorizeRequests() .antMatchers("/csrf", "/", "/webjars/**", "/swagger-resources/**").permitAll() .antMatchers("/environnement").permitAll()//PublicResources - .antMatchers("/healthcheck").permitAll() + .antMatchers(Constants.API_HEALTHCHECK).permitAll() .antMatchers("/actuator/**").permitAll() .antMatchers("/swagger-ui/*").permitAll() .antMatchers("/v3/api-docs/swagger-config", "/v3/api-docs").permitAll()