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

Implement JwtAgent, Kakao Login #15

Merged
merged 3 commits into from
Dec 9, 2023
Merged

Implement JwtAgent, Kakao Login #15

merged 3 commits into from
Dec 9, 2023

Conversation

K-Diger
Copy link
Collaborator

@K-Diger K-Diger commented Dec 7, 2023

추가사항 1. JwtAgent를 구현

프로젝트 전역으로 사용할 JWTAgent를 구현했습니다.

추가사항 2. KakaoOauth 구현

카카오 로그인 기능을 추가했습니다. 클라이언트로부터 AccessToken을 전달받도록 하였습니다.


++ Local DB에 대한 비밀번호가 달라 Jasypt를 다시 재민님 환경에 맞게 수정해주셔야할 것 같네요 ㅠ

@K-Diger K-Diger requested a review from mkSpace December 7, 2023 15:50
@K-Diger K-Diger changed the title Implement JwtAgent Implement JwtAgent, Kakao Login Dec 7, 2023
fun verifyKakao(userToken: String): String?
fun verifyKaKao(accessToken: String): String
Copy link
Collaborator

Choose a reason for hiding this comment

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

약간 워딩을 accessToken 말고 SNS임을 분명하게 해주면 좋을 것 같아요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

딱히 좋은 네이밍이 생각이 안나서 원상복구 해둘게염


private fun buildClaims(user: User): Claims {
val claims = Jwts.claims()
claims.setSubject(user.nickname.nickname)
Copy link
Collaborator

Choose a reason for hiding this comment

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

아.. nickname.nickname은 좀 구린데 이거 Wrapper면 일괄적으로 value라고 하는건 어때요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

좋습니다~

KakaoLoginResponse::class.java
)

return response.body!!.id!!
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return response.body!!.id!!
return response.body?.id!!

이렇게는 안되나요? 일단 id를 못받아오는경우 예외가 터질텐데 괜찮은가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

못받아올때의 에러처리를 따로 해봐야겠네요

@@ -6,5 +6,17 @@ import org.springframework.transaction.annotation.Transactional
@Service
@Transactional
Copy link
Collaborator

Choose a reason for hiding this comment

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

보통 여기서 readOnly = true 하고 밑에 실제 트랜잭션 동작이 있는곳에 @transactional 붙이지 않나요? readOnly의 default가 true인것 같아서요

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

저는 defaultfalse로 알고있는데 이건 그냥 저희끼리만 통일화하면 될 것 같아요~

Comment on lines 15 to 16
return user.toDto()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
val user = userRepository.findByOauthTokenPayload(payload) ?: return null
return user.toDto()
return userRepository.findByOauthTokenPayload(payload)?.toDto()

@K-Diger K-Diger merged commit 839bd46 into develop Dec 9, 2023
1 check passed
@K-Diger K-Diger deleted the feature/oauth2 branch December 9, 2023 08:14
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