Skip to content

Conversation

@user040131
Copy link
Contributor

@user040131 user040131 commented Nov 11, 2025

  1. 무슨 이유로 코드를 변경했나요?
  • kakao OAuth2를 사용한 인증/인가 로직의 구현을 위해 OAuth2UserService를 implements한 코드를 추가하였습니다.
  1. 어떤 위험이나 장애를 발견했나요?

    1. client secret state 설정 오류 -> 해당 설정 켜서 invalid credential 오류 해결
    2. 새로 생성한 테이블 UserSocial와 refreshToken의 1:N 연결에서 foreign key의 type이 달라 에러 발생 -> 타입 변경, 이미 생성된 부모 없는 row 삭제
    3. KakaoLoginSuccessHandler.onAuthenticationSuccess의 principal.getAttribute에서 인자의 이름을 userId로 설정, kakao는 해당 인자의 이름을 id로 설정하기에 에러 발생 -> 변경 후 해결
  2. 관련 스크린샷을 첨부해주세요.

스크린샷(509)
  1. 완료 사항
  • 카카오를 통한 회원 인증
  • 이를 통해 return 되는 ProviderUserId를 활용하여 db에 회원저장, refreshToken/accessToken 발급
  1. 추가사항

Copy link
Member

Choose a reason for hiding this comment

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

OAuth2 인증 후 처리 흐름을 SuccessHandler로 잘 분리해, 구조적으로 안정적인 설계를 하셨다는 부분이 인상 깊었습니다!
특히 Refresh Token을 보안 쿠키로 세심하게 설정하신 걸 보면서, 작은 디테일까지 잘 챙기신 코드라는 느낌이 들어서 많이 배우고 갑니다 😊

Comment on lines +40 to +49
Object acc = attr.get("kakao_account");
if (acc instanceof Map) {
Object profile = ((Map<?, ?>) acc).get("profile");
if (profile instanceof Map) nickname = (String) ((Map<?, ?>) profile).get("nickname");
else {
nickname = null;
}
} else {
nickname = null;
}
Copy link
Member

Choose a reason for hiding this comment

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

kakao_accountprofilenickname 으로 이어지는 중첩 구조를
단순히 캐스팅하지 않고, instanceof 로 한 단계씩 꼼꼼하게 체크해준 점이 좋은 것 같습니다!

또, 카카오 OAuth 응답은 종종 필드가 빠져 있거나 null이 내려오는 경우가 있다고 하는데,
이런 구조적 불확실성을 잘 고려해 NPE를 사전에 확실히 방지한 안전한 파싱 로직이 인상적이었습니다!! 👍🏻👍🏻

Comment on lines +44 to +45
u.setId(userId); // 레퍼런스만 set
u.setNickname(profile_nickname);

Choose a reason for hiding this comment

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

User객체를 생성하고 내부 필드값을 세팅을 하고 있지만 이후 해당 생성된 객체를 사용하지 않는 것으로 보이는데 이렇게 작성하신 이유가 있을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

해당 정적 메서드는 향후에 기존 User에 저장되어 있는 사용자와 UserSocial을 연동할 때 사용될 것으로 생각되어 제작한 메서드입니다. 아직 해당 기능은 구현하지 못해 참조없음으로 남겨두었습니다.

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