-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: mobile 전용 accessToken 발급 api 구현
- Loading branch information
Showing
5 changed files
with
68 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 24 additions & 9 deletions
33
src/main/java/com/soongsil/CoffeeChat/controller/RefreshTokenController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,53 @@ | ||
package com.soongsil.CoffeeChat.controller; | ||
|
||
import com.soongsil.CoffeeChat.controller.handler.ApiResponseGenerator; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.soongsil.CoffeeChat.config.jwt.JWTUtil; | ||
import com.soongsil.CoffeeChat.controller.handler.ApiResponseGenerator; | ||
import com.soongsil.CoffeeChat.service.CustomOAuth2UserService; | ||
import com.soongsil.CoffeeChat.service.RefreshTokenService; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController //RestController=Controller+ResponseBody | ||
@RequestMapping("/auth") | ||
@Tag(name = "REFRESHTOKEN", description = "리프레쉬 토큰 관련 api") | ||
@RequiredArgsConstructor | ||
public class RefreshTokenController { //Refresh토큰으로 Access토큰 발급 및 2차회원가입 컨트롤러 | ||
private final JWTUtil jwtUtil; | ||
private final RefreshTokenService refreshTokenService; | ||
|
||
public RefreshTokenController(JWTUtil jwtUtil, RefreshTokenService refreshTokenService) { | ||
this.jwtUtil = jwtUtil; | ||
this.refreshTokenService = refreshTokenService; | ||
} | ||
private final CustomOAuth2UserService oAuth2UserService; | ||
|
||
@PostMapping("/reissue") | ||
@Operation(summary = "리프레쉬 토큰으로 액세스 토큰 reissue") | ||
@ApiResponse(responseCode = "200", description = "헤더 : access, refresh, loginStatus") | ||
public ResponseEntity<ApiResponseGenerator<String>> reissue(HttpServletRequest request, HttpServletResponse response) { | ||
public ResponseEntity<ApiResponseGenerator<String>> reissue(HttpServletRequest request, | ||
HttpServletResponse response) { | ||
return ResponseEntity.ok().body( | ||
ApiResponseGenerator.onSuccessOK( | ||
refreshTokenService.reissueByRefreshToken(request, response) | ||
) | ||
); | ||
} | ||
|
||
@PostMapping("/reissue/mobile") | ||
@Operation(summary = "리소스 서버에서 받은 accessToken으로 서비스 accessToken 발급") | ||
@ApiResponse(responseCode = "200", description = "유효한 google accessToken으로 요청시 body로 ROLE_USER 토큰 반환") | ||
public ResponseEntity<ApiResponseGenerator<String>> issueAccessToken(@RequestParam String accessToken) { | ||
return ResponseEntity.ok().body( | ||
ApiResponseGenerator.onSuccessOK( | ||
refreshTokenService.reissueByRefreshToken(request, response) | ||
) | ||
ApiResponseGenerator.onSuccessOK( | ||
oAuth2UserService.verifyGoogleToken(accessToken) | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters