Skip to content

Commit

Permalink
feat: health-check api
Browse files Browse the repository at this point in the history
  • Loading branch information
ay-eonii committed Dec 24, 2023
1 parent 7fc5ba6 commit 15d3c64
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -40,4 +42,9 @@ public JwtResponse get(@RequestParam("code") String code) throws GeneralSecurity

return new JwtResponse(accessToken, refreshToken);
}

@GetMapping("/health-check")
public ResponseEntity<Void> checkHealthStatus() {
return new ResponseEntity<>(HttpStatus.OK);
}
}
6 changes: 6 additions & 0 deletions src/main/java/land/leets/global/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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();
Expand Down

0 comments on commit 15d3c64

Please sign in to comment.