-
Notifications
You must be signed in to change notification settings - Fork 3
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
refactor : 인가 코드 요청 및 토큰 요청 로직 #147
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2ac598d
:recycle:: 카카오 및 구글 client-id, redirect-url, base-url, client-secret 추가
Leehunil a6b9d56
:sparkles:: 카카오 인가 코드 요청 uri 작성 로직 생성
Leehunil 863c139
:sparkles:: 구글 인가 코드 요청 uri 작성 로직 생성
Leehunil 20fe7ea
:sparkles:: OauthStrategy에 추가
Leehunil da6fe5c
:recycle:: CredentialService, CredentialController에 링크 생성 로직 추가
Leehunil 3e4fcc4
:recycle:: 로그인 링크 dto 생성
Leehunil b550cf1
:recycle:: openFeign을 통해 카카오, 구글 서버에 idToken, accessToken 요청
Leehunil 9c2564c
:recycle:: yml 속성 정보 매칭
Leehunil 2b04b3d
:recycle:: CredentialService, CredentialController에 idToken, accessTo…
Leehunil 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 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
10 changes: 10 additions & 0 deletions
10
.../java/ohsoontaxi/backend/domain/credential/presentation/dto/request/OauthCodeRequest.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,10 @@ | ||
package ohsoontaxi.backend.domain.credential.presentation.dto.request; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class OauthCodeRequest { | ||
private String code; | ||
} |
11 changes: 11 additions & 0 deletions
11
...va/ohsoontaxi/backend/domain/credential/presentation/dto/response/AfterOauthResponse.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,11 @@ | ||
package ohsoontaxi.backend.domain.credential.presentation.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class AfterOauthResponse { | ||
private String idToken; | ||
private String accessToken; | ||
} |
11 changes: 11 additions & 0 deletions
11
...hsoontaxi/backend/domain/credential/presentation/dto/response/OauthLoginLinkResponse.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,11 @@ | ||
package ohsoontaxi.backend.domain.credential.presentation.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class OauthLoginLinkResponse { | ||
|
||
private String link; | ||
} |
11 changes: 11 additions & 0 deletions
11
...ava/ohsoontaxi/backend/domain/credential/presentation/dto/response/OauthTokenInfoDto.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,11 @@ | ||
package ohsoontaxi.backend.domain.credential.presentation.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class OauthTokenInfoDto { | ||
private String idToken; | ||
private String accessToken; | ||
} |
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
6 changes: 6 additions & 0 deletions
6
src/main/java/ohsoontaxi/backend/domain/credential/service/OauthStrategy.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 |
---|---|---|
@@ -1,8 +1,14 @@ | ||
package ohsoontaxi.backend.domain.credential.service; | ||
|
||
import ohsoontaxi.backend.domain.credential.presentation.dto.response.OauthTokenInfoDto; | ||
|
||
import java.security.NoSuchAlgorithmException; | ||
import java.security.spec.InvalidKeySpecException; | ||
|
||
public interface OauthStrategy { | ||
String getOauthLink(); | ||
|
||
OauthTokenInfoDto getOauthToken(String code); | ||
|
||
OIDCDecodePayload getOIDCDecodePayload(String token) throws NoSuchAlgorithmException, InvalidKeySpecException; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/ohsoontaxi/backend/global/api/client/GoogleAuthClient.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 |
---|---|---|
@@ -1,15 +1,28 @@ | ||
package ohsoontaxi.backend.global.api.client; | ||
|
||
import feign.Headers; | ||
import ohsoontaxi.backend.global.api.dto.OIDCPublicKeysResponse; | ||
import ohsoontaxi.backend.global.api.dto.OauthTokenResponse; | ||
import org.springframework.cache.annotation.Cacheable; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
|
||
@FeignClient(name = "GoogleAuthClient", url = "https://www.googleapis.com/oauth2") | ||
public interface GoogleAuthClient { | ||
|
||
@Cacheable(cacheNames = "GoogleOICD", cacheManager = "oidcCacheManager") | ||
@GetMapping("/v3/certs") | ||
OIDCPublicKeysResponse getGoogleOIDCOpenKeys(); | ||
|
||
@Headers("Content-type: application/x-www-form-urlencoded;charset=utf-8") | ||
@PostMapping( | ||
"/v4/token?code={CODE}&client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}&redirect_uri={REDIRECT_URI}&grant_type=authorization_code") | ||
OauthTokenResponse googleAuth( | ||
@PathVariable("CODE") String code, | ||
@PathVariable("CLIENT_ID") String clientId, | ||
@PathVariable("CLIENT_SECRET") String client_secret, | ||
@PathVariable("REDIRECT_URI") String redirectUri); | ||
} | ||
|
12 changes: 12 additions & 0 deletions
12
src/main/java/ohsoontaxi/backend/global/api/client/KakaoOauthClient.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 |
---|---|---|
@@ -1,14 +1,26 @@ | ||
package ohsoontaxi.backend.global.api.client; | ||
|
||
import feign.Headers; | ||
import ohsoontaxi.backend.global.api.dto.OIDCPublicKeysResponse; | ||
import ohsoontaxi.backend.global.api.dto.OauthTokenResponse; | ||
import org.springframework.cache.annotation.Cacheable; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
|
||
@FeignClient(name = "KakaoAuthClient", url = "https://kauth.kakao.com") | ||
public interface KakaoOauthClient { | ||
|
||
@Cacheable(cacheNames = "KakaoOICD", cacheManager = "oidcCacheManager") | ||
@GetMapping("/.well-known/jwks.json") | ||
OIDCPublicKeysResponse getKakaoOIDCOpenKeys(); | ||
|
||
@Headers("Content-type: application/x-www-form-urlencoded;charset=utf-8") | ||
@PostMapping( | ||
"/oauth/token?grant_type=authorization_code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&code={CODE}") | ||
OauthTokenResponse kakaoAuth( | ||
@PathVariable("CLIENT_ID") String clientId, | ||
@PathVariable("REDIRECT_URI") String redirectUri, | ||
@PathVariable("CODE") String code); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/ohsoontaxi/backend/global/api/dto/OauthTokenResponse.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 ohsoontaxi.backend.global.api.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class OauthTokenResponse { | ||
@JsonProperty("id_token") | ||
private String idToken; | ||
|
||
@JsonProperty("access_token") | ||
private String accessToken; | ||
} |
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.
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.
URLDecoder.decode를 사용하신 이유가 어떻게 되나요?
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.
인가 코드는 일회성으로 바로 보내게 되면 보안상 위험할 수 있습니다. 그래서 인가 코드를 한번 디코딩하여 보안성을 높였습니다.