Skip to content

[feat] 로그인 완료 후 회원 정보 조회시 Access · RefreshToken 반환 #98

Merged
LEEDONGH00N merged 7 commits intowith-travel:developfrom
iamseojin:feat/issue-#41
Aug 3, 2025
Merged

[feat] 로그인 완료 후 회원 정보 조회시 Access · RefreshToken 반환 #98
LEEDONGH00N merged 7 commits intowith-travel:developfrom
iamseojin:feat/issue-#41

Conversation

@iamseojin
Copy link
Contributor

이슈

구현 기능

로그인 직후 /signup/register 엔드포인트에서 AccessToken과 RefreshToken을 회원 정보와 함께 반환하도록 동작 수정

  1. AccessToken response body 로 전달

프론트에서 로그인처리에 사용할 수 있도록 로그인 직후 AccessToken을 발급하여 회원 정보와 함께 response body에 포함하여 반환합니다.

  1. RefreshTokenHttpOnly 쿠키로 전달

RefreshToken은 AccessToken보다 유효기간이 길어 탈취로 인한 보안 위험이 존재합니다.
따라서 브라우저의 JavaScript에서 접근이 불가능한 HttpOnly 쿠키로 전달하도록 변경하여 XSS 공격을 대비하였습니다.

@iamseojin iamseojin changed the title [feat] 로그인 완료 시 AccessToken 반환 및 RefreshToken은 HttpOnly 쿠키로 분리 전달 [feat] 로그인 완료 후 회원 정보 조회시 Access · RefreshToken 반환 Aug 2, 2025
Comment on lines +74 to +80
ResponseCookie cookie = ResponseCookie.from(jwtProperties.getRefreshCookieName(), refreshToken)
.httpOnly(true)
.secure(true)
.path("/")
.maxAge(Duration.ofDays(jwtProperties.getRefreshTokenExpireDays()))
.build();
response.addHeader(HttpHeaders.SET_COOKIE, cookie.toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

쿠키 설정 없이 문자열만 있으면 될 것 같습니다.

@LEEDONGH00N LEEDONGH00N requested a review from Copilot August 3, 2025 10:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements token-based authentication after login completion by modifying the /signup/register endpoint to return both AccessToken and RefreshToken along with member information. The RefreshToken is securely delivered as an HttpOnly cookie to prevent XSS attacks, while the AccessToken is included in the response body for frontend use.

  • Added token generation and cookie handling functionality to the signup flow
  • Modified the member signup endpoint to return tokens along with member data
  • Enhanced JWT configuration with expiration settings and cookie configuration

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
TokenService.java Added issueTokenPair method to generate access/refresh tokens and set HttpOnly cookie
AuthTokenResponse.java New DTO class to hold access and refresh token pair
JwtProperties.java Added JWT expiration configuration and refresh cookie name property
MemberSignupTokenResponse.java New response DTO combining member signup data with authentication tokens
MemberSignupController.java Modified GET endpoint to return tokens along with member information

.build();
response.addHeader(HttpHeaders.SET_COOKIE, cookie.toString());

return new AuthTokenResponse(accessToken, refreshToken);
Copy link

Copilot AI Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refresh token is being returned in the response body, which contradicts the security goal stated in the PR description. Since the refresh token is already set as an HttpOnly cookie, it should not be included in the response body to maintain security.

Suggested change
return new AuthTokenResponse(accessToken, refreshToken);
return new AuthTokenResponse(accessToken);

Copilot uses AI. Check for mistakes.
LEEDONGH00N and others added 3 commits August 3, 2025 19:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…nupTokenResponse.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@LEEDONGH00N LEEDONGH00N merged commit 3fc875d into with-travel:develop Aug 3, 2025
5 checks passed
@iamseojin iamseojin deleted the feat/issue-#41 branch August 5, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants