-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 카카오톡 로그인 구현 #56
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
7df66dc
build: spring-security, jwt, webclient 의존성 추가
7fa0346
feat: 카카오 로그인 API 및 비즈니스 로직 추가
cd1afaa
fix(KakaoAuthClient): 토큰 API 요청 시 중복 URL path 제거
dddafa0
refactor(KakaoApiUrlConstant): 카카오 API Url 상수 클래스 추가
5b41a88
fix: yml에서 key값 받아올 수 있도록 변경
b5cab08
feat: 회원가입 로직 추가
a365087
style: 메서드명 수정: getAccessToekn -> oAuthLogin
4594989
style: createAuthorizationRedirectUri 매개변수명 수정
11b7e9c
Merge remote-tracking branch 'origin/develop' into feature/login-kakao
43cd6ef
build: weblcient 의존성 추가
eb3e143
fix: 카카오 로그인 오류 수정
47549aa
feat: JWT토큰 필터 추가
f8e6fca
feat: ArgumentResolver 추가 및 resovler 내에 사용자 인가 로직 추가
55c324c
feat: @auth 어노테이션으로 사용자 정보 불러오도록 수정
4f5b13b
Merge remote-tracking branch 'origin/develop' into feature/login-kakao
5516b5a
feat: 사용자 정보 조회 API 추가
e42f829
refactor: 불필요한 코드 제거
c4ad3bf
chore: yml 파일 수정
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
This file contains hidden or 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
7 changes: 7 additions & 0 deletions
7
src/main/java/kr/kro/photoliner/common/dto/response/JwtResponse.java
This file contains hidden or 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,7 @@ | ||
| package kr.kro.photoliner.common.dto.response; | ||
|
|
||
| public record JwtResponse( | ||
| String accessToken | ||
| ) { | ||
|
|
||
| } |
This file contains hidden or 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
3 changes: 0 additions & 3 deletions
3
src/main/java/kr/kro/photoliner/domain/album/dto/request/AlbumCreateRequest.java
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
40 changes: 40 additions & 0 deletions
40
src/main/java/kr/kro/photoliner/domain/user/controller/UserController.java
This file contains hidden or 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 |
|---|---|---|
| @@ -1,12 +1,52 @@ | ||
| package kr.kro.photoliner.domain.user.controller; | ||
|
|
||
| import java.net.URI; | ||
| import kr.kro.photoliner.common.dto.response.JwtResponse; | ||
| import kr.kro.photoliner.domain.user.dto.response.UserInfoResponse; | ||
| import kr.kro.photoliner.domain.user.service.UserService; | ||
| import kr.kro.photoliner.global.auth.Auth; | ||
| import kr.kro.photoliner.global.kakao.login.service.KakaoAuthService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| 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; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/v1/users") | ||
| public class UserController { | ||
|
|
||
| private final UserService userService; | ||
| private final KakaoAuthService kakaoAuthService; | ||
| private static final String LOGIN_REDIRECT_URL = "http://localhost:5173/login/kakao"; | ||
|
|
||
| @GetMapping("/login/kakao") | ||
| public ResponseEntity<JwtResponse> login(@RequestParam(value = "code") String authorizationCode) { | ||
| JwtResponse jwtResponse = userService.oAuthLogin(authorizationCode); | ||
|
|
||
| String redirectUrl = LOGIN_REDIRECT_URL + "#accessToken=" + jwtResponse.accessToken(); | ||
|
|
||
| return ResponseEntity | ||
| .status(HttpStatus.FOUND) | ||
| .location(URI.create(redirectUrl)) | ||
| .build(); | ||
| } | ||
|
|
||
| @GetMapping("/login/kakao/authorization") | ||
| public ResponseEntity<Void> authorize() { | ||
| return ResponseEntity | ||
| .status(HttpStatus.FOUND) | ||
| .location(URI.create(kakaoAuthService.getAuthorizationRedirectUrl())) | ||
| .build(); | ||
| } | ||
|
|
||
| @GetMapping("/info") | ||
| public ResponseEntity<UserInfoResponse> getUserInfo( | ||
| @Auth Long userId | ||
| ) { | ||
| return ResponseEntity.ok(userService.getUserInfo(userId)); | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/main/java/kr/kro/photoliner/domain/user/dto/request/UserRefreshTokenRequest.java
This file contains hidden or 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,12 @@ | ||
| package kr.kro.photoliner.domain.user.dto.request; | ||
|
|
||
| import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| @JsonNaming(value = SnakeCaseStrategy.class) | ||
| public record UserRefreshTokenRequest( | ||
| @NotNull(message = "refresh token 을 입력해주세요.") | ||
| String refreshToken | ||
| ) { | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/main/java/kr/kro/photoliner/domain/user/dto/response/UserInfoResponse.java
This file contains hidden or 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,16 @@ | ||
| package kr.kro.photoliner.domain.user.dto.response; | ||
|
|
||
| import kr.kro.photoliner.domain.user.model.User; | ||
|
|
||
| public record UserInfoResponse( | ||
| String name, | ||
| String email | ||
| ) { | ||
|
|
||
| public static UserInfoResponse from(User user) { | ||
| return new UserInfoResponse( | ||
| user.getName(), | ||
| user.getEmail() | ||
| ); | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
RestClient대안도 존재하는데 무거운 웹플럭스 사용하신 이유가 궁금합니다!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.
찾아보니 webflux는 스프링부트 개발환경에 적합하지 않다고 나오네요..
추후 시간이 된다면
RestClient로 변경해 보겠습니다!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.
webflux,RestClient각 기술이 가진 장단점을 비교분석 후 선택했으면 더 좋지 않았을까 싶네요👍