From bc6f21bf5a839e1f7996a993eca0b4f6fc1514c8 Mon Sep 17 00:00:00 2001 From: adorableco Date: Sat, 21 Sep 2024 21:03:32 +0900 Subject: [PATCH] =?UTF-8?q?HOTFIX:=20health=20check=20=EC=9A=A9=20api=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../phote/common/authority/JwtAuthenticationFilter.kt | 5 ++--- .../phote/common/authority/SecurityConfig.kt | 2 +- .../phote/controller/HealthCheckController.kt | 11 +++++++++++ 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 src/main/kotlin/com/swm_standard/phote/controller/HealthCheckController.kt diff --git a/.gitignore b/.gitignore index 0c97b2f..ec903a0 100644 --- a/.gitignore +++ b/.gitignore @@ -156,3 +156,4 @@ application.properties .gradle build resources +/newrelic/newrelic.yml diff --git a/src/main/kotlin/com/swm_standard/phote/common/authority/JwtAuthenticationFilter.kt b/src/main/kotlin/com/swm_standard/phote/common/authority/JwtAuthenticationFilter.kt index b0ec4d2..b87ff65 100644 --- a/src/main/kotlin/com/swm_standard/phote/common/authority/JwtAuthenticationFilter.kt +++ b/src/main/kotlin/com/swm_standard/phote/common/authority/JwtAuthenticationFilter.kt @@ -17,9 +17,8 @@ class JwtAuthenticationFilter( chain: FilterChain?, ) { val accessToken = resolveToken(request as HttpServletRequest) - if (accessToken != null && - jwtTokenProvider.validateToken(accessToken) && - request.getHeader("userAgent")?.contains("ELB-HealthChecker/2.0") == false + + if (accessToken != null && jwtTokenProvider.validateToken(accessToken) ) { val authentication = jwtTokenProvider.getAuthentication(accessToken) SecurityContextHolder.getContext().authentication = authentication diff --git a/src/main/kotlin/com/swm_standard/phote/common/authority/SecurityConfig.kt b/src/main/kotlin/com/swm_standard/phote/common/authority/SecurityConfig.kt index 00255b4..8412530 100644 --- a/src/main/kotlin/com/swm_standard/phote/common/authority/SecurityConfig.kt +++ b/src/main/kotlin/com/swm_standard/phote/common/authority/SecurityConfig.kt @@ -23,7 +23,7 @@ class SecurityConfig( .sessionManagement { it.sessionCreationPolicy(SessionCreationPolicy.STATELESS) } .authorizeHttpRequests { it - .requestMatchers("/api/auth/*") + .requestMatchers("/api/auth/*", "/") .anonymous() .requestMatchers("/v3/**", "/swagger-ui/**", "api/token") .permitAll() diff --git a/src/main/kotlin/com/swm_standard/phote/controller/HealthCheckController.kt b/src/main/kotlin/com/swm_standard/phote/controller/HealthCheckController.kt new file mode 100644 index 0000000..f6c7833 --- /dev/null +++ b/src/main/kotlin/com/swm_standard/phote/controller/HealthCheckController.kt @@ -0,0 +1,11 @@ +package com.swm_standard.phote.controller + +import com.swm_standard.phote.common.responsebody.BaseResponse +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +class HealthCheckController { + @GetMapping("/") + fun healthCheck(): BaseResponse = BaseResponse(data = "정상 작동 중") +}