Skip to content

Commit

Permalink
add :: endpoint 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
ta2ye0n committed Nov 4, 2024
1 parent ebd5e20 commit 025a63c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.gcms.v3.domain.auth.presentation.data.request.SignInRequestDto;
import com.gcms.v3.domain.auth.presentation.data.response.TokenInfoResponseDto;
import com.gcms.v3.domain.auth.service.LogoutService;
import com.gcms.v3.domain.auth.service.ReissueTokenService;
import com.gcms.v3.domain.auth.service.SignInService;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
Expand All @@ -15,6 +17,7 @@ public class AuthController {

private final SignInService signInService;
private final ReissueTokenService reissueTokenService;
private final LogoutService logoutService;

@PostMapping
public ResponseEntity<TokenInfoResponseDto> signIn (@RequestBody SignInRequestDto signInRequestDto) {
Expand All @@ -27,4 +30,10 @@ public ResponseEntity<TokenInfoResponseDto> reissueToken (@RequestBody String re
TokenInfoResponseDto res = reissueTokenService.execute(refreshToken);
return ResponseEntity.ok(res);
}

@DeleteMapping("/logout")
public ResponseEntity<Void> logout(HttpServletRequest request) {
logoutService.execute(request);
return ResponseEntity.noContent().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
authorizeRequests
.requestMatchers(HttpMethod.POST, "/v3/auth").permitAll()
.requestMatchers(HttpMethod.POST, "/v3/auth/reissueToken").authenticated()
.requestMatchers(HttpMethod.DELETE, "/v3/auth/logout").authenticated()
)

.addFilterBefore(new ExceptionFilter(objectMapper), UsernamePasswordAuthenticationFilter.class)
Expand Down

0 comments on commit 025a63c

Please sign in to comment.