-
Notifications
You must be signed in to change notification settings - Fork 0
[IDLE-323] refactor: 애플 소셜로그인 리팩터링 #20
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
Open
0112leesy
wants to merge
3
commits into
develop
Choose a base branch
from
refactor/IDLE-323
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
30 changes: 30 additions & 0 deletions
30
...rary/userservice/authentication/domain/oauth2/converter/CustomRequestEntityConverter.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,30 @@ | ||
| package kr.mybrary.userservice.authentication.domain.oauth2.converter; | ||
|
|
||
| import kr.mybrary.userservice.authentication.domain.oauth2.service.AppleOAuth2UtilService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.core.convert.converter.Converter; | ||
| import org.springframework.http.RequestEntity; | ||
| import org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest; | ||
| import org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequestEntityConverter; | ||
| import org.springframework.util.MultiValueMap; | ||
|
|
||
| @Slf4j | ||
| @RequiredArgsConstructor | ||
| public class CustomRequestEntityConverter implements Converter<OAuth2AuthorizationCodeGrantRequest, RequestEntity<?>> { | ||
|
|
||
| private final OAuth2AuthorizationCodeGrantRequestEntityConverter defaultConverter; | ||
| private final AppleOAuth2UtilService appleOAuth2UtilService; | ||
|
|
||
| @Override | ||
| public RequestEntity<?> convert(OAuth2AuthorizationCodeGrantRequest request) { | ||
| RequestEntity<?> entity = defaultConverter.convert(request); | ||
| String registrationId = request.getClientRegistration().getRegistrationId(); | ||
| MultiValueMap<String, String> params = (MultiValueMap<String, String>) entity.getBody(); | ||
| if(registrationId.contains("apple")) { | ||
| params.set("client_secret", appleOAuth2UtilService.createAppleClientSecret( | ||
| request.getClientRegistration().getClientId(), request.getClientRegistration().getClientSecret())); | ||
| } | ||
| return new RequestEntity<>(params, entity.getHeaders(), entity.getMethod(), entity.getUrl()); | ||
| } | ||
| } | ||
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
25 changes: 25 additions & 0 deletions
25
...a/kr/mybrary/userservice/authentication/domain/oauth2/userinfo/AppleOAuth2UserInfoV2.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,25 @@ | ||
| package kr.mybrary.userservice.authentication.domain.oauth2.userinfo; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| public class AppleOAuth2UserInfoV2 extends OAuth2UserInfo { | ||
|
|
||
| public AppleOAuth2UserInfoV2(Map<String, Object> attributes) { | ||
| super(attributes); | ||
| } | ||
|
|
||
| @Override | ||
| public String getId() { | ||
| return (String) attributes.get("sub"); | ||
| } | ||
|
|
||
| @Override | ||
| public String getNickname() { | ||
| return (String) attributes.get("emailId"); | ||
| } | ||
|
|
||
| @Override | ||
| public String getEmail() { | ||
| return (String) attributes.get("email"); | ||
| } | ||
| } |
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
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.
r3 : 매직넘버를 상수로 처리하면 좋을 것 같습니다.