-
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.
Merge pull request #47 from GOAT-WAAAM/dev/encJ/oauth-naver
[FEAT] 네이버 소셜로그인 추가
- Loading branch information
Showing
6 changed files
with
119 additions
and
4 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
1 change: 0 additions & 1 deletion
1
src/main/java/com/goat/server/auth/dto/request/KakaoLoginParams.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
18 changes: 18 additions & 0 deletions
18
src/main/java/com/goat/server/auth/dto/request/NaverLoginParams.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,18 @@ | ||
package com.goat.server.auth.dto.request; | ||
|
||
import com.goat.server.auth.domain.type.OAuthProvider; | ||
|
||
public record NaverLoginParams( | ||
String naverAccessToken | ||
) implements OAuthLoginParams { | ||
|
||
@Override | ||
public OAuthProvider oAuthProvider() { | ||
return OAuthProvider.NAVER; | ||
} | ||
|
||
@Override | ||
public String accessToken() { | ||
return naverAccessToken; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/goat/server/auth/dto/response/NaverInfoResponse.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,39 @@ | ||
package com.goat.server.auth.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.databind.PropertyNamingStrategies; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
import com.goat.server.auth.domain.type.OAuthProvider; | ||
import lombok.Builder; | ||
|
||
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) | ||
@Builder | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record NaverInfoResponse( | ||
|
||
Response response | ||
|
||
) implements OAuthInfoResponse { | ||
|
||
@Override | ||
public Long getId() { | ||
return response.id(); | ||
} | ||
|
||
@Override | ||
public String getNickname() { | ||
return response.nickname(); | ||
} | ||
|
||
@Override | ||
public OAuthProvider getOAuthProvider() { | ||
return OAuthProvider.NAVER; | ||
} | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record Response( | ||
Long id, | ||
String nickname | ||
) { | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/goat/server/auth/util/NaverApiClient.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,23 @@ | ||
package com.goat.server.auth.util; | ||
|
||
import com.goat.server.auth.domain.type.OAuthProvider; | ||
import com.goat.server.auth.dto.response.NaverInfoResponse; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
|
||
@FeignClient(name = "naverApiClient", url = "${oauth.naver.service.api_url}") | ||
@Component | ||
public interface NaverApiClient extends OAuthApiClient { | ||
|
||
@Override | ||
@GetMapping(value = "/v1/nid/me") | ||
NaverInfoResponse requestOauthInfo(@RequestHeader(HttpHeaders.AUTHORIZATION) String accessToken); | ||
|
||
@Override | ||
default OAuthProvider oAuthProvider() { | ||
return OAuthProvider.NAVER; | ||
} | ||
} |
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