-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 사용자 목록 조회 구현 #232
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
Merged
Merged
feat: 사용자 목록 조회 구현 #232
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d8f8226
feat: cursor 세팅
shong9124 167d684
feat: 사용자 목록 조회 구현
shong9124 4debf51
fix: csrf 토큰 관련 수정
shong9124 aceb65b
test: 테스트 추가 및 수정
shong9124 289a9dd
fix: csrf 토큰이 만료되던 문제 해결
shong9124 61a74d9
fix: csrf 토큰 관련 코드 삭제
shong9124 8bd914c
fix: 코드래빗 리뷰반영 - 조회 상한값 설정
shong9124 cbc3799
fix: 정렬시 dto 바인딩 문제 수정
shong9124 3cd54fb
fix: 코드래빗 리뷰반영 - 잘못된 커서 입력값에 대한 처리
shong9124 1aa04f5
fix: 코드래빗 리뷰반영 - swagger 문서 작성 누락 반영
shong9124 cef12a7
fix: 수정하면서 누락된 어노테이션 복구
shong9124 b4bffb5
test: 테스트 수정
shong9124 f06f2eb
fix: 코드래빗 리뷰반영 - 커서 파라미터 관련 로직 수정
shong9124 c21e48b
test: 테스트 수정
shong9124 565d58b
fix: 코드래빗 리뷰반영 - 인증에서 누락되는 메서드 보완
shong9124 7e33cc1
fix: 코드래빗 리뷰반영 - 테스트 추가
shong9124 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
38 changes: 38 additions & 0 deletions
38
src/main/java/com/codeit/team5/mopl/auth/handler/SpaCsrfTokenRequestHandler.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,38 @@ | ||
| package com.codeit.team5.mopl.auth.handler; | ||
|
|
||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import jakarta.servlet.http.HttpServletResponse; | ||
| import java.util.function.Supplier; | ||
| import org.springframework.security.web.csrf.CsrfToken; | ||
| import org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler; | ||
| import org.springframework.security.web.csrf.CsrfTokenRequestHandler; | ||
| import org.springframework.security.web.csrf.XorCsrfTokenRequestAttributeHandler; | ||
| import org.springframework.util.StringUtils; | ||
|
|
||
| public final class SpaCsrfTokenRequestHandler implements CsrfTokenRequestHandler { | ||
|
|
||
| private final CsrfTokenRequestHandler plain = new CsrfTokenRequestAttributeHandler(); | ||
| private final CsrfTokenRequestHandler xor = new XorCsrfTokenRequestAttributeHandler(); | ||
|
|
||
| @Override | ||
| public void handle( | ||
| HttpServletRequest request, | ||
| HttpServletResponse response, | ||
| Supplier<CsrfToken> csrfToken | ||
| ) { | ||
| // 응답 렌더링 시 BREACH 방어 | ||
| this.xor.handle(request, response, csrfToken); | ||
| // 지연 토큰 강제 로드 -> 쿠키에 기록 | ||
| csrfToken.get(); | ||
| } | ||
|
|
||
| @Override | ||
| public String resolveCsrfTokenValue(HttpServletRequest request, CsrfToken csrfToken) { | ||
| String headerValue = request.getHeader(csrfToken.getHeaderName()); | ||
|
|
||
| // 헤더(X-XSRF-TOKEN)로 온 raw 토큰은 plain, 그 외는 xor로 해석 | ||
| return StringUtils.hasText(headerValue) | ||
| ? this.plain.resolveCsrfTokenValue(request, csrfToken) | ||
| : this.xor.resolveCsrfTokenValue(request, csrfToken); | ||
| } | ||
| } |
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/codeit/team5/mopl/user/constant/UserSortBy.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,26 @@ | ||
| package com.codeit.team5.mopl.user.constant; | ||
|
|
||
| import com.codeit.team5.mopl.user.exception.InvalidUserSortByException; | ||
| import java.util.Arrays; | ||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Getter | ||
| @RequiredArgsConstructor | ||
| public enum UserSortBy { | ||
| NAME("name"), | ||
| EMAIL("email"), | ||
| CREATED_AT("createdAt"), | ||
| LOCKED("isLocked"), | ||
| ROLE("role") | ||
|
shong9124 marked this conversation as resolved.
|
||
| ; | ||
|
|
||
| private final String value; | ||
|
|
||
| public static UserSortBy from(String value) { | ||
| return Arrays.stream(values()) | ||
| .filter(sortBy -> sortBy.value.equalsIgnoreCase(value)) | ||
| .findFirst() | ||
| .orElseThrow(() -> new InvalidUserSortByException(value)); | ||
| } | ||
| } | ||
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
29 changes: 29 additions & 0 deletions
29
src/main/java/com/codeit/team5/mopl/user/dto/request/UserCursorRequest.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,29 @@ | ||
| package com.codeit.team5.mopl.user.dto.request; | ||
|
|
||
| import com.codeit.team5.mopl.user.constant.UserSortBy; | ||
| import com.codeit.team5.mopl.user.entity.UserRole; | ||
| import jakarta.validation.constraints.Max; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Positive; | ||
| import java.util.UUID; | ||
| import org.springframework.data.domain.Sort; | ||
|
|
||
| public record UserCursorRequest( | ||
| String emailLike, | ||
| UserRole roleEqual, | ||
| Boolean isLocked, | ||
| String cursor, | ||
| UUID idAfter, | ||
|
|
||
| @NotNull | ||
| @Positive | ||
| @Max(100) | ||
| Integer limit, | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| @NotNull | ||
| Sort.Direction sortDirection, | ||
|
|
||
| @NotNull | ||
| UserSortBy sortBy | ||
| ) { | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
src/main/java/com/codeit/team5/mopl/user/exception/InvalidUserSortByException.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,11 @@ | ||
| package com.codeit.team5.mopl.user.exception; | ||
|
|
||
| import com.codeit.team5.mopl.global.exception.BusinessException; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| public class InvalidUserSortByException extends BusinessException { | ||
|
|
||
| public InvalidUserSortByException(String value) { | ||
| super(HttpStatus.BAD_REQUEST, "정렬 입력값이 올바르지 않습니다. value=" + value ); | ||
| } | ||
| } |
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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/codeit/team5/mopl/user/repository/querydsl/UserQueryRepository.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,13 @@ | ||
| package com.codeit.team5.mopl.user.repository.querydsl; | ||
|
|
||
| import com.codeit.team5.mopl.user.dto.request.UserCursorRequest; | ||
| import com.codeit.team5.mopl.user.entity.User; | ||
| import java.util.List; | ||
|
|
||
| public interface UserQueryRepository { | ||
|
|
||
| List<User> findUsers(UserCursorRequest request, int fetchLimit); | ||
|
|
||
| long countUsers(UserCursorRequest request); | ||
|
|
||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.