-
Notifications
You must be signed in to change notification settings - Fork 0
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
[LIME-122] 카카오 소셜 로그인 처리 방식 수정 #63
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8695497
chore : 소셜로그인 사용 방식 변경으로 인한 oauth2의존성 제거
HandmadeCloud 285f2a4
feat : 카카오 소셜로그인 code를 받아 처리하는 비즈니스 로직 구현
HandmadeCloud 17d4d60
refactor : 소셜 id long타입으로 변경
HandmadeCloud 098c363
feat : 카카오 전용 토큰 요청 및 수신 dto 생성
HandmadeCloud 71911d1
refactor: 카카오 소셜로그인 방식 변경으로 인한 security 설정 변경
HandmadeCloud e145506
refactor : property 추가로 인한 스캔 범위 수정
HandmadeCloud 5d9ba7d
chore : 개행 수정
HandmadeCloud 9c935dd
fix : gradle 소셜로그인 의존성 제거 및 프로퍼티 적용 의존성 추가
HandmadeCloud 79aa60c
chore : 각종 handler, entrypoint 시도중
HandmadeCloud 9dd6d04
chore : 파일 이동
HandmadeCloud 68683b6
refactor : 인가처리 단계에서 권한 확인 후 인증처리 전 프로필 업데이트 양식으로 리다이렉트 처리
HandmadeCloud f2332eb
chore : 사용하지 않는 코드 정리
HandmadeCloud 188a92a
refactor : join페이지로 리다이렉트, 해당 권한 승인 처리
HandmadeCloud 05d9cf0
refactor : refreshToken전달방식 변경
HandmadeCloud 2f94280
chore : 컨벤션 및 사용 문법 수정
HandmadeCloud 852f50e
refactor : 레이어 역참조 문제 해결
HandmadeCloud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
lime-api/src/main/java/com/programmers/lime/domains/auth/api/AuthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.programmers.lime.domains.auth.api; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.programmers.lime.domains.auth.application.OAuthUserService; | ||
import com.programmers.lime.domains.member.api.dto.response.MemberLoginResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api") | ||
@RestController | ||
public class AuthController { | ||
|
||
private final OAuthUserService oauthUserService; | ||
|
||
@GetMapping("/auth/kakao/callback") | ||
public ResponseEntity<MemberLoginResponse> loginKakao( | ||
@RequestParam final String code | ||
) { | ||
return ResponseEntity.ok(oauthUserService.login(code)); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
lime-api/src/main/java/com/programmers/lime/domains/auth/application/OAuthUserService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.programmers.lime.domains.auth.application; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.programmers.lime.domains.auth.api.dto.KakaoMemberResponse; | ||
import com.programmers.lime.domains.member.api.dto.response.MemberLoginResponse; | ||
import com.programmers.lime.domains.member.domain.Member; | ||
import com.programmers.lime.domains.member.domain.vo.SocialType; | ||
import com.programmers.lime.domains.member.implementation.MemberAppender; | ||
import com.programmers.lime.domains.member.implementation.MemberReader; | ||
import com.programmers.lime.global.config.security.jwt.JwtService; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class OAuthUserService { | ||
|
||
private final KakaoOAuthClient kakaoOAuthClient; | ||
private final MemberAppender memberAppender; | ||
private final MemberReader memberReader; | ||
private final JwtService jwtService; | ||
|
||
@Transactional | ||
public MemberLoginResponse login(String code) { | ||
String kakaoAccessToken = kakaoOAuthClient.getAccessToken(code); | ||
KakaoMemberResponse response = kakaoOAuthClient.getMemberInfo(kakaoAccessToken); | ||
|
||
Member foundMember = memberReader.readBySocialIdAndSocialType( | ||
response.id(), | ||
SocialType.KAKAO | ||
).orElseGet(() -> saveMember(response)); | ||
|
||
String accessToken = jwtService.generateAccessToken(String.valueOf(foundMember.getId())); | ||
String refreshToken = jwtService.generateRefreshToken(); | ||
|
||
return MemberLoginResponse.from(foundMember, accessToken, refreshToken); | ||
} | ||
|
||
private Member saveMember(final KakaoMemberResponse response) { | ||
return memberAppender.append(response.toEntity()); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p1;
final 키워드 추가 해주세여!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2f94280 반영 완료