Skip to content

feat: oauth2 로그인#8

Merged
west-eastH merged 14 commits intodevelopfrom
feat/7-oauth2
Jun 30, 2025
Merged

feat: oauth2 로그인#8
west-eastH merged 14 commits intodevelopfrom
feat/7-oauth2

Conversation

@west-eastH
Copy link
Contributor

✨ 연관된 이슈

close #7


📝 작업 내용 (주요 변경 사항)

  • 멤버 엔티티 정의
  • JWT 관련 클래스 추가
  • OAuth2 관련 인터페이스 & 클래스 추가
  • OAuth2 로그인 구현

💬 리뷰 요구사항

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

  • createdAt, updatedAt, deletedAt 하나로 묶어서 사용하는거 알려주세요,,
  • SignupResponse에서 팩토리 메서드 패턴 사용하긴 했는데 null null null null이 들어가서 더 좋은 방법 있으면 코멘트 남겨주세요!

저희 테스트 커버리지가 너무 높은 것 같은듯,, 서지님 한번 해보시고 같이 조정해봐요~

@west-eastH west-eastH requested a review from choiseoji June 29, 2025 13:15
@west-eastH west-eastH self-assigned this Jun 29, 2025
@west-eastH west-eastH added the ✨feat 기능 개발 시 label Jun 29, 2025
@west-eastH west-eastH linked an issue Jun 29, 2025 that may be closed by this pull request
2 tasks
@github-actions
Copy link

Test Coverage Report

Overall Project 46.31% -36.19%
Files changed 55.58%

File Coverage
GoogleUserInfo.java 100% 🍏
SignupRequest.java 100% 🍏
SignupResponse.java 100% 🍏
TokenResponse.java 100% 🍏
Role.java 100% 🍏
OAuthType.java 100% 🍏
Gender.java 100% 🍏
ExceptionCode.java 100% 🍏
Member.java 100% 🍏
AuthService.java 98% -2% 🍏
CustomUserDetails.java 46.34% -53.66%
JwtTokenProvider.java 1.92% -98.08%
OAuth2UserInfoFactory.java 0%
SecurityConfig.java 0%
JwtAuthenticationFilter.java 0%
CodeRequest.java 0%
AuthController.java 0%

Copy link
Contributor

@choiseoji choiseoji left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!!
너무 너무 깔끔한 코드여서 나중에 많이 참고하겠습니다 ~ 😃

Comment on lines +1 to +17
.PHONY: all build down re

all: build copy up

build:
@./gradlew clean build

copy:
@cp ./build/libs/backend-0.0.1-SNAPSHOT.jar ./app.jar

up:
@docker compose up --build -d

down:
@docker compose down

re: down up No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

혹시 makefile 어디에 사용되는건가요??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

이거 빌드하고 docker compose 돌리는거 귀찮아서 만들었어요😅

Comment on lines +3 to +5
public record TokenResponse(String accessToken, String refreshToken) {

}
Copy link
Contributor

Choose a reason for hiding this comment

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

토큰 헤더에 안 넣고 body에 담아서 보내주는게 더 나을까요??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

앱은 어떻게 처리해야 될 지 몰라서 우선 body에 담았는데 한번 찾아볼게요!!

Comment on lines +112 to +121
public String generateSignupToken(String providerId, String provider, String email, String name) {
long now = (new Date()).getTime();
return Jwts.builder()
.setSubject(providerId)
.claim("provider", provider)
.claim("email", email)
.claim("name", name)
.setExpiration(new Date(now + 600000))
.signWith(key, SignatureAlgorithm.HS256)
.compact();
Copy link
Contributor

Choose a reason for hiding this comment

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

이건 그냥 저희 signup api 를 호출하기 위한 토큰인거죠 ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

맞아요 추가 정보 받을 때 사용할 임시 토큰이용

TokenResponse response = authService.completeSignup(signupRequest);

return ResponseEntity.ok(new CommonResponse<>("회원가입이 완료되었습니다.", response));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

accessToken 만료 되었을 때 재발급하는 api 가 없어서 이것만 있으면 될거 같아요!!
accessToken 발급할때 refeshToken도 새로 발급하는 RTR 방식 사용해도 좋을거 같아요!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

재발급 api 까먹,, RTR 방식 찾아보고 수정할게요!!

Comment on lines +3 to +16
public record SignupResponse(boolean isNewUser, String signupToken, String email, String name,
String provider, TokenResponse tokens) {

public static SignupResponse forExistingUser(TokenResponse tokens) {
//기존 회원은 토큰만 리턴
return new SignupResponse(false, null, null, null, null, tokens);
}

public static SignupResponse forNewUser(String signupToken, String email, String name,
String provider) {
//신규 회원은 회원가입을 위한 정보와 임시 토큰 리턴
return new SignupResponse(true, signupToken, email, name, provider, null);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

null이 많긴 하지만 좋은거 같아요!!
null 없이 하려면 인터페이스 만들어서 forExistingUser 용 response, forNewUser 용 response 를 따로 구현하는 방법도 추천받았는데, 지금 방식이 더 나은 것 같아요

Comment on lines +50 to +54
private LocalDateTime createdAt;

private LocalDateTime updatedAt;

private LocalDateTime deletedAt;
Copy link
Contributor

Choose a reason for hiding this comment

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

아 이거 baseEntity 만들어서 extends 하면 되는거라서
제가 엔티티 만들면서 추가해두겠습니다!!


import run.backend.domain.member.enums.Gender;

public record SignupRequest(String signupToken, String nickname, Gender gender, int age, String profileImage) {
Copy link
Contributor

Choose a reason for hiding this comment

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

SignupResponse에 이미지 관련 필드는 없는거 같은데 profileImage는 어디서 받아오는 건가요??
만약, 유저가 직접 업로드하는 거라면 파일로 받아서 처리해야 될거 같아요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

이거 구글에서 제공해주는 사용자 프로필 생각했는데 그거 말고 저희 추가 정보 받는 곳에서 파일로 받도록 수정할게요!

@github-actions
Copy link

Test Coverage Report

Overall Project 53.21% -39.65% 🍏
Files changed 57.3% 🍏

File Coverage
SignupRequest.java 100% 🍏
SignupResponse.java 100% 🍏
TokenResponse.java 100% 🍏
Role.java 100% 🍏
OAuthType.java 100% 🍏
Gender.java 100% 🍏
Member.java 100% 🍏
AuthService.java 81.51% -18.49% 🍏
RefreshToken.java 70.59% -29.41% 🍏
FileService.java 9.84% -90.16%
FileController.java 0%
CodeRequest.java 0%
AuthController.java 0%


@PostMapping("/refresh")
public ResponseEntity<CommonResponse<TokenResponse>> refresh(
@RequestHeader("Authorization") String authorizationHeader) {
Copy link
Contributor

Choose a reason for hiding this comment

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

오 대박 이렇게 가지고 올 수 있는거 처음 알았어요

@github-actions
Copy link

Test Coverage Report

Overall Project 53.21% -39.65% 🍏
Files changed 57.3% 🍏

File Coverage
SignupRequest.java 100% 🍏
SignupResponse.java 100% 🍏
TokenResponse.java 100% 🍏
Role.java 100% 🍏
OAuthType.java 100% 🍏
Gender.java 100% 🍏
Member.java 100% 🍏
AuthService.java 81.51% -18.49% 🍏
RefreshToken.java 70.59% -29.41% 🍏
FileService.java 9.84% -90.16%
FileController.java 0%
CodeRequest.java 0%
AuthController.java 0%

@west-eastH west-eastH merged commit 6631c64 into develop Jun 30, 2025
1 check passed
@west-eastH west-eastH deleted the feat/7-oauth2 branch June 30, 2025 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨feat 기능 개발 시

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨feat : OAuth2 회원가입

2 participants