Skip to content

Conversation

@kangtayie
Copy link

@kangtayie kangtayie commented Nov 11, 2025

#122

1. 어떤 이유로 코드를 변경했나요?

  • 기존 로그인 로직에서는 자체 회원가입만 지원하고, 소셜 로그인이 없었습니다.
    -> 카카오 OAuth 2.0 인증을 도입하여 사용자가 별도 회원가입 없이 간편하게 로그인할 수 있도록 개선했습니다.
  • 인증 로직 일부를 리팩토링하여 DB 조회 없이도 JwtAuthenticationFilter가 토큰만으로 Authentication을 생성할 수 있도록 개선했습니다.
  • Refresh Token 저장 로직과 매핑 엔티티(RefreshToken, User)를 추가해, 로그인/재발급 과정에서 토큰이 DB에 안전하게 저장 및 검증되도록 했습니다.

2. 어떤 위험이나 장애를 발견했나요?

  • 카카오 access_token 유효성 검증 문제
    -> 카카오 API 호출 시 401 Unauthorized가 반복 발생
  • Refresh Token 저장 누락 이슈
    -> 로그인 성공 시 토큰이 발급되지만 DB에 저장되지 않음
  • Refresh Token 불일치로 인한 500 오류
    -> 클라이언트에서 전달한 refreshToken이 DB 저장값과 일치하지 않아 서버 에러 발생

3. 스크린 샷

스크린샷 2025-11-25 233326

@kangtayie kangtayie self-assigned this Nov 11, 2025
Copy link

@sxvxnxwt sxvxnxwt left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!! 에러 해결이 잘 되었으면 좋겠네요..🍀🍀

Choose a reason for hiding this comment

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

클라이언트로부터 AccessToken을 먼저 받지 말고 인가코드를 먼저 받아 그 코드로 카카오 API와 통신해서 AccessToken을 받도록 로직을 수정하면 401 에러는 해결될 거 같습니다!! 😸

Copy link

@sispo3314 sispo3314 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!! 저와 다르게 구현하신 부분이 많아서 잘 읽었습니당ㅎㅎ
그리고 JwtEntryPoint를 따로 구현하신 것 같은데 이렇게 했을 때 어떤 점이 좋은 지 궁금합니다!!

Comment on lines +40 to +46
// 로그아웃
@PostMapping("/logout")
public ResponseEntity<ApiResponse<Void>> logout(@RequestParam String email) {
authService.logout(email);
return ResponseEntity.ok(ApiResponse.onSuccess("Logged out"));
}
}

Choose a reason for hiding this comment

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

현재 로그아웃을 할 때 URL 쿼리 파라미터로 이메일을 받고 있는데, 이 코드는 현재 로그인한 사용자가 아닌 파라미터로 넘어온 다른 사용자를 로그아웃 시킬 수 있는 보안상의 위험이 있다고 합니다!! 로그아웃은 현재 인증된 사용자를 기준으로 처리해주시면 좋을 것 같아요 👍🏻👍🏻

Jwts.parser().setSigningKey(key).build().parseClaimsJws(token);
return true;
} catch (JwtException | IllegalArgumentException ex) {
return false;

Choose a reason for hiding this comment

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

지금 validationToken 메서드에서 예외 발생 시 false만 반환하고 있는데, 어떤 이유로 토큰 검증에 실패했는지 로그에 남기면 디버깅에 도움이 된다고 합니다!

} catch (JwtException | IllegalArgumentException ex) {
    log.warn("Invalid JWT token: {}", ex.getMessage()); 
    return false;
}

이런식으로 하는 게 좋다고 하네요 저도 몰랐는데 알아갑니당 👀👀

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