Skip to content

Commit

Permalink
Merge pull request #131 from Team-GAJI/feature/#130-query-access/GAJI…
Browse files Browse the repository at this point in the history
…-138

⚙[setting] #130 - 쿼리로 access 토큰 전달
  • Loading branch information
mmingoo authored Aug 20, 2024
2 parents ad2badd + e10ff32 commit f98fae0
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/main/java/gaji/service/jwt/service/CustomSuccessHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo


// 2. body에 담아서 보낼 경우 Access 토큰을 JSON 응답으로 전송
// Map<String, String> tokenResponse = new HashMap<>();
// tokenResponse.put("access_token", accessToken);
//
// response.setContentType(MediaType.APPLICATION_JSON_VALUE);
// response.setCharacterEncoding("UTF-8");
// response.getWriter().write(objectMapper.writeValueAsString(tokenResponse));
// response.setStatus(HttpStatus.OK.value());
Map<String, String> tokenResponse = new HashMap<>();
tokenResponse.put("access_token", accessToken);

response.setContentType(MediaType.APPLICATION_JSON_VALUE);
response.setCharacterEncoding("UTF-8");
response.getWriter().write(objectMapper.writeValueAsString(tokenResponse));
response.setStatus(HttpStatus.OK.value());

// 토큰 로그로 남기기
log.info("accessToken = {}", accessToken);
Expand All @@ -93,12 +93,12 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo


// // 리다이렉션 URL 생성
// String targetUrl = UriComponentsBuilder.fromUriString(finalRedirectionUrl)
// .queryParam("access_token", accessToken)
// .build().toUriString();
String targetUrl = UriComponentsBuilder.fromUriString(finalRedirectionUrl)
.queryParam("access_token", accessToken)
.build().toUriString();

// 리다이렉션 수행
getRedirectStrategy().sendRedirect(request, response, finalRedirectionUrl);
getRedirectStrategy().sendRedirect(request, response, targetUrl);
}

private void addRefreshEntity(String username, String refresh, Long expiredMs) {
Expand Down

0 comments on commit f98fae0

Please sign in to comment.