From 15d3c64b9f29aa6367db202fe09949403a731ec4 Mon Sep 17 00:00:00 2001 From: ay-eonii Date: Sun, 24 Dec 2023 14:53:42 +0900 Subject: [PATCH] feat: health-check api --- .../domain/auth/presentation/AuthController.java | 13 ++++++++++--- .../land/leets/global/config/SecurityConfig.java | 6 ++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/land/leets/domain/auth/presentation/AuthController.java b/src/main/java/land/leets/domain/auth/presentation/AuthController.java index 2638881..959b207 100644 --- a/src/main/java/land/leets/domain/auth/presentation/AuthController.java +++ b/src/main/java/land/leets/domain/auth/presentation/AuthController.java @@ -12,15 +12,17 @@ import land.leets.global.jwt.JwtProvider; import land.leets.global.jwt.dto.JwtResponse; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.*; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import java.io.IOException; import java.security.GeneralSecurityException; @RestController @RequiredArgsConstructor -@Slf4j public class AuthController { private final AuthService authService; private final JwtProvider jwtProvider; @@ -40,4 +42,9 @@ public JwtResponse get(@RequestParam("code") String code) throws GeneralSecurity return new JwtResponse(accessToken, refreshToken); } + + @GetMapping("/health-check") + public ResponseEntity checkHealthStatus() { + return new ResponseEntity<>(HttpStatus.OK); + } } diff --git a/src/main/java/land/leets/global/config/SecurityConfig.java b/src/main/java/land/leets/global/config/SecurityConfig.java index 13e4adc..8c50a76 100644 --- a/src/main/java/land/leets/global/config/SecurityConfig.java +++ b/src/main/java/land/leets/global/config/SecurityConfig.java @@ -51,6 +51,9 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { http .authorizeHttpRequests() .requestMatchers(CorsUtils::isCorsRequest).permitAll() + + .requestMatchers(HttpMethod.GET,"/health-check").permitAll() + .requestMatchers("/v3/api-docs/**", "/swagger-ui/**").permitAll() .requestMatchers("/oauth2/**", "/auth/**").permitAll() @@ -71,6 +74,9 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .requestMatchers(HttpMethod.GET,"/application/**").hasAuthority(AuthRole.ROLE_ADMIN.getRole()) .requestMatchers(HttpMethod.PATCH,"/application/**").hasAuthority(AuthRole.ROLE_ADMIN.getRole()) + .requestMatchers(HttpMethod.GET,"/interview").permitAll() + .requestMatchers(HttpMethod.PATCH,"/interview/**").hasAuthority(AuthRole.ROLE_ADMIN.getRole()) + .requestMatchers(HttpMethod.POST,"/mail/**").hasAuthority(AuthRole.ROLE_ADMIN.getRole()) .anyRequest().authenticated();