Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.util.UriComponentsBuilder;

import com.whereyouad.WhereYouAd.global.response.DataResponse;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import java.util.UUID;

@RestController
Expand All @@ -42,8 +43,7 @@ public class GoogleAdOAuthController implements GoogleAdOAuthDocs {

// 구글 연동 로그인 화면으로 리다이렉트
@GetMapping("/login")
public ResponseEntity<Void> redirectToGoogleAuth(@RequestParam("orgId") Long orgId, @AuthenticationPrincipal(expression = "userId") Long userId,
HttpServletResponse response) throws IOException {
public ResponseEntity<DataResponse<Map<String, String>>> redirectToGoogleAuth(@RequestParam("orgId") Long orgId, @AuthenticationPrincipal(expression = "userId") Long userId) {

String stateToken = UUID.randomUUID().toString();
String rawState = userId + "_" + orgId;
Expand All @@ -59,12 +59,7 @@ public ResponseEntity<Void> redirectToGoogleAuth(@RequestParam("orgId") Long org
"&prompt=consent" +
"&state=" + stateToken;

URI location = URI.create(authUrl);

return ResponseEntity
.status(HttpStatus.FOUND)
.location(location)
.build();
return ResponseEntity.ok(DataResponse.from(Map.of("redirectUrl", authUrl)));
}

@GetMapping("/callback")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.web.bind.annotation.RequestParam;

import java.io.IOException;
import java.util.Map;

public interface GoogleAdOAuthDocs {

Expand All @@ -19,9 +20,8 @@ public interface GoogleAdOAuthDocs {
"인증이 완료되면 사전에 등록된 콜백(callback) URI로 인증 코드(code)와 상태 값(state)이 반환됩니다."
)
@GetMapping("/login")
ResponseEntity<Void> redirectToGoogleAuth(@Parameter @RequestParam("orgId") Long orgId,
@Parameter(hidden = true) @AuthenticationPrincipal(expression = "userId") Long userId,
HttpServletResponse response) throws IOException;
ResponseEntity<DataResponse<Map<String, String>>> redirectToGoogleAuth(@Parameter @RequestParam("orgId") Long orgId,
@Parameter(hidden = true) @AuthenticationPrincipal(expression = "userId") Long userId);

@Operation(
summary = "구글 OAuth 인증 콜백 및 리프레시 토큰 발급",
Expand Down
Loading