Skip to content
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

[Feature] - 카카오 로그인 구현 #55

Merged
merged 23 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2583cc9
feat: OAuth 요청에 대한 응답 DTO 작성
Libienz Jul 17, 2024
63ccece
chore: Jasypt 의존성 추가
Libienz Jul 18, 2024
778d1b6
feat: 카카오 OAuth Client 객체 구현
Libienz Jul 18, 2024
11684f3
feat: OAuthProvider 구현
Libienz Jul 18, 2024
ce2e4e0
feat: Login 서비스, 컨트롤러 구현
Libienz Jul 18, 2024
b0a0b00
feat: 소셜 로그인 회원가입 분기 흐름 구현
nak-honest Jul 18, 2024
20198e3
feat: jwt를 통한 로그인 기능 구현
slimsha2dy Jul 18, 2024
4b52f2c
chore: 디버깅 출력 문구 삭제
slimsha2dy Jul 18, 2024
8e979a2
chore: 머지 충돌 해결
Libienz Jul 18, 2024
4535fc0
fix: jasypt 시크릿 키를 github action에서 환경 변수로 지정
nak-honest Jul 18, 2024
c265ab2
fix: github action에서 빌드 시 jasypt secret key를 환경변수로 받도록 변경
nak-honest Jul 18, 2024
c03e945
feat: 카카오 OAuth 로그인 redirect uri 프로파일별로 분리
nak-honest Jul 19, 2024
554e846
fix: 테스트 용 config yml 파일 분리 및 테스트에서 jasypt 제거
Libienz Jul 19, 2024
5d6f4c0
chore: 로컬용 jwt 비밀키와 개발 서버용 키 분리
Libienz Jul 19, 2024
c42b09e
chore: 데이터베이스 정보 관리 환경변수 방식에서 jasypt 방식으로 변경
Libienz Jul 19, 2024
859fce1
refactor: DTO inner 클래스 가독성 위해서 별도의 record로 분리
Libienz Jul 19, 2024
efa9892
refactor: 카카오 유저 정보 응답 DTO nested record로 개선
Libienz Jul 19, 2024
f4406a4
style: 괄호 재배치, 공백 문자 가독성 개선
Libienz Jul 19, 2024
deff84e
refactor: RestClient 설정 기능 생성자에서 분리 개선
Libienz Jul 19, 2024
b9ec188
refactor: 하드 코딩된 헤더 정보 미리 제공되는 상수로 변경
Libienz Jul 19, 2024
2b4913b
refactor: 사용되지 않는 생성자 접근 제어 레벨 개선
Libienz Jul 19, 2024
62049b0
chore: github action에서 빌드 시 환경 변수를 지정하지 않도록 변경
nak-honest Jul 19, 2024
46bcaac
Merge branch 'develop/be' into feature/be/#47
Libienz Jul 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class JwtTokenProvider {

public JwtTokenProvider(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public JwtTokenProvider(
public JwtTokenProvider(
@Value("${security.jwt.token.secret-key}") String secretKey,
@Value("${security.jwt.token.expire-length}") long validityInMilliseconds
) {
this.secretKey = secretKey;
this.validityInMilliseconds = validityInMilliseconds;
}

괄호 내려주면 다른 파일이랑 컨벤션이 더 잘 맞을 것 같습니다

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영 완!

@Value("${security.jwt.token.secret-key}") String secretKey,
@Value("${security.jwt.token.expire-length}") long validityInMilliseconds) {
@Value("${security.jwt.token.expire-length}") long validityInMilliseconds
) {
this.secretKey = secretKey;
this.validityInMilliseconds = validityInMilliseconds;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.ClientHttpRequestFactories;
import org.springframework.boot.web.client.ClientHttpRequestFactorySettings;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.stereotype.Component;
Expand All @@ -20,7 +21,6 @@ public class KakaoOauthClient {
private final String accessTokenRequestUri;
private final String restApiKey;
private final String redirectUri;

private final RestClient restClient;

public KakaoOauthClient(
Expand All @@ -29,17 +29,21 @@ public KakaoOauthClient(
@Value("${oauth.kakao.rest-api-key}") String restApiKey,
@Value("${oauth.kakao.redirect-uri}") String redirectUri
) {
this.userInformationRequestUri = userInformationRequestUri;
this.accessTokenRequestUri = accessTokenRequestUri;
this.restApiKey = restApiKey;
this.redirectUri = redirectUri;
this.restClient = buildRestClient();
}

private RestClient buildRestClient() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

걍 의견) build말고 getRestClient 이런 네이밍이 더 직관적일 수도 있을 것 같네용?

ClientHttpRequestFactorySettings settings = ClientHttpRequestFactorySettings.DEFAULTS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

생성자 로직이 많은 것 같아서 메서드로 빼면 어떨깝쇼

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋을것 같답쇼 분리했습니답쇼

.withConnectTimeout(Duration.ofSeconds(1))
.withReadTimeout(Duration.ofSeconds(3));

ClientHttpRequestFactory requestFactory = ClientHttpRequestFactories.get(settings);

this.userInformationRequestUri = userInformationRequestUri;
this.accessTokenRequestUri = accessTokenRequestUri;
this.restApiKey = restApiKey;
this.redirectUri = redirectUri;
this.restClient = RestClient.builder()
return RestClient.builder()
.requestFactory(requestFactory)
.build();
}
Expand All @@ -49,7 +53,7 @@ public OauthUserInformationResponse requestUserInformation(String authorizationC

return restClient.get()
.uri(userInformationRequestUri)
.header("Authorization", "Bearer " + kakaoAccessTokenResponse.accessToken())
.header(HttpHeaders.AUTHORIZATION, "Bearer " + kakaoAccessTokenResponse.accessToken())
.retrieve()
.toEntity(OauthUserInformationResponse.class)
.getBody();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import woowacourse.touroot.entity.BaseEntity;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
@Entity
public class Member extends BaseEntity {
Expand Down
Loading