-
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
feat: 회원 annotation 기능 추가 및 테스트 인터페이스 제공 #62
Merged
Merged
Changes from 67 commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
2cb3959
feat: 회원 엔티티 생성 및 테스트코드 추가
parksey 3c119f8
feat: 카카오 OAuth 환경변수 추가 및 클래스 바인딩
parksey 729d7d2
feat: authorization code를 받기 위한 queryString generator 추가
parksey 9cbfc2e
feat: Authorization code의 parameter 만드는 로직 분리 및 테스트 코드 추가
parksey e056905
feat: 회원 가입/로그인 요청 api 및 소셜 로그인 페이지 반환
parksey 0dc50e4
refactor: member관련 클래스 네이밍과 폴더 위치 변경
parksey 233661a
refactor: 로그인 페이지 요청 방식 Resttemplate -> response (redirect)하도록 변경
parksey 18f3496
style: 코드 포맷 재적용 및 사용하지 않는 클래스 삭제
parksey a1e7533
chore: config 파일 업데이트
parksey b5163eb
refactor: 테스트 코드 추가 및 코드 포맷 재적용
parksey 9c10d45
refactor: 사용하지 않는 코드 제거
parksey 92cb531
refactor: CRLF -> LF로 변경
parksey a7291a8
fix: config 커밋, config 최근 커밋으로 변경
parksey 47ef3ea
feat: 테스트 코드 추가 및 패키지 구조 변경
parksey 5a76a50
refactor: revert merge
parksey ab0063d
Merge branch 'develop' into feature/#5
parksey ab0b0ab
fix: merge confilt해결 및 예외처리 추가
parksey dff5e2e
test: oauth properties가 없을 때의 테스트코드 추가
parksey 31407ab
feat: 코드리뷰에 따른 기능 분리 및 테스트 코드 변경
parksey 448011e
fix: 테스트코드 관련 code smell 제거
parksey c421394
feat: Authorization grant 받기 예외 코드 및 테스트 코드 추가
parksey 40cac6f
refactor: develop브랜치 merge
parksey 36a64b1
feat: Authorization Token 요청 및 반환 코드, 에러 반환 테스트 코드 추가
parksey 1eb8eb4
refactor: AuthenticationService에서 서버에 요청보내는 로직 OAuth2AuthorizationSer…
parksey 5ef8308
test: 로그인 요청 테스트 코드 추가
parksey 82925fa
feat: 토큰 발급 요청 기능 테스트 코드 추가 및 RestTemplate 필드변수로 변경
parksey 95bea5d
refactor: develop 브랜치 merge
parksey 7e53464
test: restTemplate 및 서비스 테스트 추가
parksey 41b234b
refactor: 에러 메세지 이름 변경
parksey dffed00
refacotr: 변수명 및 entity default 명 변경
parksey 5c32df9
feat: 토큰 정보 조회 기능 및 테스트 추가
parksey 436dbdc
feat: 사용자 토큰 정보 조회 및 테스트 코드 & Resttemplate 테크트 코드 변경
parksey 5b94df4
refactor: develop 브랜치 merge
parksey 9995d28
Merge branch 'develop' of https://github.com/team-moabam/moabam-BE in…
parksey f58059b
fix: encoding, formatting, tab 문제로 인한 파일 삭제 후 다시 작성
parksey d1db0e4
feat: JWT 토큰 제공 서비스 및 테스트 코드 추가
parksey 7862353
feat: 토큰 인증 코드 및 테스트 코드 작성
parksey dbf9488
feat: 로그인 및 회원가입 기능 추가
parksey 5aa6cc0
feat: 회원 로그인 테스트 코드 추가
parksey cf030fc
chore: 코드 포메팅 재 설정
parksey f706306
Merge branch 'develop' of https://github.com/team-moabam/moabam-BE in…
parksey 64d1609
refactor: develop 변경사항 merge
parksey 672840e
feat: config 파일 업데이트
parksey 0759ebb
refactor: develop 기능 merge
parksey 9080613
fix: MemberServie confilt 해결
parksey 00b1fe0
feat: Window용 포트 redis 포트 변경 추가
parksey 42ddbd6
Merge branch 'develop' of https://github.com/team-moabam/moabam-BE in…
parksey 4b00b42
refacotr: develop 업데이트 사항 merge
parksey b9b90f2
refactor: develop 업데이트 부분 merge
parksey 3294470
fix: TimeConfig 삭제 및 코드 스멜 변경
parksey dafef37
refactor: 코르리뷰 반영
parksey 66c441f
chore: submodule update
parksey 7aa7292
refactor: develop 추가 기능 반영
parksey ded282f
feat: 메서드 파싱 customizing 및 @CurrentMember AuthorizationMember 를 파라미터로…
parksey 66f56af
feat: 인가회원에 대한 객체 ThreadLocalMap에 저장하는 기능 추가
parksey 91899f1
fix: 회원 정보 Optional 정보 조회 버그 fix, socialId requiredNotNull추가 등 에러 수정
parksey 6b69352
feat: API요청 Path 및 인증에 따른 filter 추가
parksey fe34db0
test: CurrentMember 테스트 support 추가
parksey c1c921e
test: authorizationfilter 및 pathfilter 테스트 추가
parksey 62a9369
test: 회원 repostiory 및 fixture 추가
parksey ff3cb3b
test: filter support 클랠스 추가
parksey 1ab3913
test: filter support 클래스 적용
parksey cc929c0
refactor: develop 브랜치와 merge
parksey 0df1440
refactor: PublicClaim 변환 책임 변경
parksey 30225cb
test: PathResolver, CurrentMemberArgumentResovler테스트 코드 추가
parksey 495938b
fix: 모든 쿠키 secure 적용되도록 변경
parksey 3bfa398
refactor: 클래스 명 변경
parksey 7922976
refactor: webConfig Path 매핑 클래스 추가
parksey e7f451f
refactor: develop 업데이트 merge
parksey 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,10 @@ | |
|
||
import org.springframework.stereotype.Service; | ||
|
||
import com.moabam.api.dto.PublicClaim; | ||
import com.moabam.global.config.TokenConfig; | ||
|
||
import io.jsonwebtoken.JwtBuilder; | ||
import io.jsonwebtoken.Jwts; | ||
import io.jsonwebtoken.SignatureAlgorithm; | ||
import lombok.RequiredArgsConstructor; | ||
|
@@ -16,15 +18,27 @@ public class JwtProviderService { | |
|
||
private final TokenConfig tokenConfig; | ||
|
||
public String provideAccessToken(long id) { | ||
return generateToken(id, tokenConfig.getAccessExpire()); | ||
public String provideAccessToken(PublicClaim publicClaim) { | ||
return generateIdToken(publicClaim, tokenConfig.getAccessExpire()); | ||
} | ||
|
||
public String provideRefreshToken(long id) { | ||
return generateToken(id, tokenConfig.getRefreshExpire()); | ||
public String provideRefreshToken() { | ||
return generateCommonInfo(tokenConfig.getRefreshExpire()); | ||
Comment on lines
+21
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: 하나의 메서드에서 하나의 메서드를 호출하는 것 같은데, 메서드를 한 번 더 감싼 이유가 있나요? |
||
} | ||
|
||
private String generateToken(long id, long expireTime) { | ||
private String generateIdToken(PublicClaim publicClaim, long expireTime) { | ||
return commonInfo(expireTime) | ||
.claim("id", publicClaim.id()) | ||
.claim("nickname", publicClaim.nickname()) | ||
.claim("role", publicClaim.role()) | ||
.compact(); | ||
} | ||
|
||
private String generateCommonInfo(long expireTime) { | ||
return commonInfo(expireTime).compact(); | ||
} | ||
|
||
Comment on lines
+29
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C: 이를 그대로 사용하면 되지 않나? 생각이 듭니다! |
||
private JwtBuilder commonInfo(long expireTime) { | ||
Date issueDate = new Date(); | ||
Date expireDate = new Date(issueDate.getTime() + expireTime); | ||
|
||
|
@@ -34,8 +48,6 @@ private String generateToken(long id, long expireTime) { | |
.setIssuer(tokenConfig.getIss()) | ||
.setIssuedAt(issueDate) | ||
.setExpiration(expireDate) | ||
.claim("id", id) | ||
.signWith(tokenConfig.getKey(), SignatureAlgorithm.HS256) | ||
.compact(); | ||
.signWith(tokenConfig.getKey(), SignatureAlgorithm.HS256); | ||
} | ||
} |
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
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 com.moabam.api.dto; | ||
|
||
import com.moabam.api.domain.entity.enums.Role; | ||
|
||
public record AuthorizationMember( | ||
Long id, | ||
String nickname, | ||
Role role | ||
) { | ||
|
||
} |
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,11 +1,13 @@ | ||
package com.moabam.api.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonUnwrapped; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record LoginResponse( | ||
Long id, | ||
boolean isSignUp | ||
boolean isSignUp, | ||
@JsonUnwrapped PublicClaim publicClaim | ||
) { | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.moabam.api.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.moabam.api.domain.entity.enums.Role; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record PublicClaim( | ||
Long id, | ||
@JsonIgnore String nickname, | ||
@JsonIgnore Role role | ||
) { | ||
|
||
} |
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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/moabam/global/common/annotation/CurrentMember.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,12 @@ | ||
package com.moabam.global.common.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target({ElementType.PARAMETER}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface CurrentMember { | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/moabam/global/common/handler/CurrentMemberArgumentResolver.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,31 @@ | ||
package com.moabam.global.common.handler; | ||
|
||
import static com.moabam.global.common.util.AuthorizationThreadLocal.*; | ||
|
||
import java.util.Objects; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import org.springframework.core.MethodParameter; | ||
import org.springframework.web.bind.support.WebDataBinderFactory; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.method.support.ModelAndViewContainer; | ||
|
||
import com.moabam.api.dto.AuthorizationMember; | ||
import com.moabam.global.common.annotation.CurrentMember; | ||
|
||
public class CurrentMemberArgumentResolver implements HandlerMethodArgumentResolver { | ||
|
||
@Override | ||
public boolean supportsParameter(MethodParameter parameter) { | ||
return Objects.nonNull(parameter.getParameterAnnotation(CurrentMember.class)) | ||
&& parameter.getParameterType().equals(AuthorizationMember.class); | ||
} | ||
|
||
@Override | ||
public Object resolveArgument(@Nullable MethodParameter parameter, ModelAndViewContainer mavContainer, | ||
@Nullable NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { | ||
return getAuthorizationMember(); | ||
} | ||
} |
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.
Q: 매직넘버를 따로 안한 이유가 궁금합니다!
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.
관련 클래스 다 삭제!