-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FEAT] 소셜 로그인 기능 구현
- Loading branch information
Showing
23 changed files
with
497 additions
and
50 deletions.
There are no files selected for viewing
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
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
15 changes: 15 additions & 0 deletions
15
src/main/java/com/umc/networkingService/config/security/jwt/TokenInfo.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,15 @@ | ||
package com.umc.networkingService.config.security.jwt; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
public class TokenInfo { | ||
|
||
private String accessToken; | ||
private String refreshToken; | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/umc/networkingService/domain/member/client/AppleMemberClient.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,30 @@ | ||
package com.umc.networkingService.domain.member.client; | ||
|
||
import com.umc.networkingService.domain.member.dto.client.AppleResponse; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
|
||
@Component | ||
public class AppleMemberClient { | ||
private WebClient webClient; | ||
|
||
public AppleMemberClient(WebClient.Builder webclientBuilder){ | ||
this.webClient = webclientBuilder | ||
.baseUrl("https://appleid.apple.com/auth/keys") | ||
.build(); | ||
} | ||
|
||
public String getappleClientID(final String accessToken){ | ||
AppleResponse response = webClient.get() | ||
.header("Authorization", "Bearer " + accessToken) | ||
.retrieve() | ||
.bodyToMono(AppleResponse.class) | ||
.block(); | ||
|
||
//TODO 정보 받기 실패 예외 처리 | ||
if(response == null) | ||
return null; | ||
|
||
return response.getSub(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/umc/networkingService/domain/member/client/GoogleMemberClient.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,31 @@ | ||
package com.umc.networkingService.domain.member.client; | ||
|
||
import com.umc.networkingService.domain.member.dto.client.GoogleResponse; | ||
import com.umc.networkingService.global.common.exception.ErrorCode; | ||
import com.umc.networkingService.global.common.exception.RestApiException; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
|
||
@Component | ||
public class GoogleMemberClient { | ||
private final WebClient webClient; | ||
|
||
public GoogleMemberClient(WebClient.Builder webClientBuilder){ | ||
this.webClient = webClientBuilder | ||
.baseUrl("https://www.googleapis.com/oauth2/v3/userinfo") | ||
.build(); | ||
} | ||
|
||
public String getgoogleClientID(final String accessToken) { | ||
GoogleResponse response = webClient.get() | ||
.header("Authorization", "Bearer " + accessToken) | ||
.retrieve() | ||
.bodyToMono(GoogleResponse.class) | ||
.block(); | ||
|
||
if(response == null) | ||
throw new RestApiException(ErrorCode._INTERNAL_SERVER_ERROR); | ||
|
||
return response.getSub(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/umc/networkingService/domain/member/client/KakaoMemberClient.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,33 @@ | ||
package com.umc.networkingService.domain.member.client; | ||
|
||
import com.umc.networkingService.domain.member.dto.client.KakaoResponse; | ||
import com.umc.networkingService.global.common.exception.ErrorCode; | ||
import com.umc.networkingService.global.common.exception.RestApiException; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
|
||
@Component | ||
public class KakaoMemberClient { | ||
|
||
private final WebClient webClient; | ||
|
||
|
||
public KakaoMemberClient(WebClient.Builder webClientBuilder ) { | ||
this.webClient = webClientBuilder | ||
.baseUrl("https://kapi.kakao.com/v2/user/me") | ||
.build(); | ||
} | ||
|
||
public String getkakaoClientID(final String accessToken) { | ||
KakaoResponse response = webClient.get() | ||
.header("Authorization", "Bearer " + accessToken) | ||
.retrieve() | ||
.bodyToMono(KakaoResponse.class) | ||
.block(); | ||
|
||
if(response == null) | ||
throw new RestApiException(ErrorCode._INTERNAL_SERVER_ERROR); | ||
|
||
return response.getId(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/umc/networkingService/domain/member/client/NaverMemberClient.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,32 @@ | ||
package com.umc.networkingService.domain.member.client; | ||
|
||
import com.umc.networkingService.domain.member.dto.client.NaverResponse; | ||
import com.umc.networkingService.global.common.exception.ErrorCode; | ||
import com.umc.networkingService.global.common.exception.RestApiException; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
|
||
@Component | ||
public class NaverMemberClient { | ||
|
||
private final WebClient webClient; | ||
|
||
public NaverMemberClient(WebClient.Builder webClientBuilder){ | ||
this.webClient=webClientBuilder | ||
.baseUrl("https://openapi.naver.com/v1/nid/me") | ||
.build(); | ||
} | ||
|
||
public String getnaverClientID(final String accessToken){ | ||
NaverResponse response=webClient.get() | ||
.header("Authorization","Bearer "+ accessToken) | ||
.retrieve() | ||
.bodyToMono(NaverResponse.class) | ||
.block(); | ||
|
||
if(response == null) | ||
throw new RestApiException(ErrorCode._INTERNAL_SERVER_ERROR); | ||
|
||
return response.getResponse().getId(); | ||
} | ||
} |
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
17 changes: 0 additions & 17 deletions
17
src/main/java/com/umc/networkingService/domain/member/dto/MemberResponseDto.java
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
src/main/java/com/umc/networkingService/domain/member/dto/client/AppleResponse.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,8 @@ | ||
package com.umc.networkingService.domain.member.dto.client; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class AppleResponse { | ||
private String sub; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/umc/networkingService/domain/member/dto/client/GoogleResponse.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,8 @@ | ||
package com.umc.networkingService.domain.member.dto.client; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class GoogleResponse { | ||
private String sub; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/umc/networkingService/domain/member/dto/client/KakaoResponse.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,8 @@ | ||
package com.umc.networkingService.domain.member.dto.client; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class KakaoResponse { | ||
private String id; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/umc/networkingService/domain/member/dto/client/NaverResponse.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,13 @@ | ||
package com.umc.networkingService.domain.member.dto.client; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class NaverResponse { | ||
private Response response; | ||
|
||
@Getter | ||
public static class Response { | ||
private String id; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/umc/networkingService/domain/member/dto/response/MemberLoginResponse.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,15 @@ | ||
package com.umc.networkingService.domain.member.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.util.UUID; | ||
|
||
@Getter | ||
@Builder | ||
public class MemberLoginResponse { | ||
private UUID memberId; | ||
private String accessToken; | ||
private String refreshToken; | ||
} |
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
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
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
Oops, something went wrong.