Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(SignUp): 카카오 회원가입, jwt 로그인 구현 #21

Merged
merged 24 commits into from
Jul 15, 2024

Conversation

InHyeok-J
Copy link
Contributor

@InHyeok-J InHyeok-J commented Jul 11, 2024

PR 변경된 내용

  • idToken 기반 회원가입 / 로그인 기능 구현 (카카오 구현됨)
  • Member Oauthserver type 수정
  • jwt, oidc public key cache 적용
  • usecase -> application 패키지로 auth쪽만 변경

추가 내용

참조

  • 한번에 구현한 양이 많아 google 로그인은 따로 issue를 받아서 처리할 예정(issue 카카오 회원가입 로그인 #20) 수정하겠습니다.
  • 저번에 예기한 Auth 도메인 Token객체는 추후 논의 필요 (아무런 로직이 없는 것 같아서 제외시킴)
  • Test코드는 PR올리고 추가로 작성해 올리겠습니다(오늘 5시 전에 PR 올리려고 미리 올렸음)

Test 추가 내용

DTO 검증

  • Request Dto(LoginRequest)
  • OauthServer의 처리를 위해 enum 값 검사 처리.
  • 사용법
// enumClass 에 Enum 객체를 명시한다.
// Type이 String인 값을 입력 받아 Enum의 값과 맞는지 처리한다.
 @EnumValid(enumClass = OauthServer.class, message = "oauthServer Type이 잘못됐습니다.")
  • 해당 DTO 객체를 java-validation 환경에서 Test를 동작하도록 처리함

kakaoClient에 대한 예외처리

  • infra에 NetworkApiException 클래스와 ErrorCode를 추가, Config 설정에 예외 처리
        RestClient client = RestClient.builder()
                .baseUrl("https://kauth.kakao.com")
                .defaultStatusHandler(HttpStatusCode::isError, ((request, response) -> {
                    throw new NetworkApiException(NetworkApiErrorCode.KAKAO_JWK_API_FAIL);
                }))
                .build();
  • 사용
    private List<OidcPublicKey> getOidcPublicKeyByKakaoClient() {
        try {
            ResponseEntity<OidcPublicKeyResponse> publicKeys = kakaoKauthClient.getPublicKeys();
            return publicKeys.getBody().getKeys();
        } catch (NetworkApiException e) {
            log.error(e.getMessage()); //logging 및 application의 BusinessException으로 핸들링 할 수 있게 다시 처리함.

            throw new AuthenticationBusinessException(AuthenticationErrorCode.GET_JWK_FAIL);
        }
    }
  • infra에서도 실패에 대한 처리 및, 호출하는 코드(애플리케이션)에서도 전 처리 할 수 있게 사용하면 좋을듯

논의가 필요한 내용

  • JWT의 정책(유효기간, 키 관리 등)

Closed: #20

@InHyeok-J InHyeok-J self-assigned this Jul 11, 2024
@InHyeok-J InHyeok-J closed this Jul 11, 2024
@InHyeok-J InHyeok-J reopened this Jul 11, 2024
Copy link
Member

@morenow98 morenow98 left a comment

Choose a reason for hiding this comment

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

OIDC 쪽 코드를 너무 잘 짜신 것 같아요! 밑에 질문드린 게 좀 많지만,,,,
LGTM😁

@InHyeok-J InHyeok-J requested a review from morenow98 July 12, 2024 10:04
@InHyeok-J InHyeok-J requested a review from morenow98 July 15, 2024 03:17
@InHyeok-J InHyeok-J merged commit e8a3a3c into develop Jul 15, 2024
1 check passed
@morenow98 morenow98 deleted the feature/20-signup branch July 19, 2024 05:55
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.

카카오 회원가입 로그인
2 participants