-
Notifications
You must be signed in to change notification settings - Fork 1
#28 추가 + swagger3.0 version #32
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
base: dev
Are you sure you want to change the base?
Conversation
- createTree
- TreeRequestDto 추가 및 @Valid검사 - TreeList - TreeListResponseDto추가 - List데이터가 변경될수 있기때문에 TreeList 추가 - deleteTree - @PathVariable treeId값으로 트리삭제
- TreeDetailResponseDto 추가 (treeitem 필드 필요) - 상세정보를 위한 modelMapper 추가
- TreeDetailResponseDto 추가 (treeitem 필드 필요) - 상세정보를 위한 modelMapper 추가
Tree, TreeItem entity - id값을 String으로 변경에 따른 service, controller 수정 Tree Controller - createTree, treeDetail, treeModify 반환값을 TreeDetailResponseDto 로수정 - treeDetail로 트리 상세정보 가져올 때 트리아이템 목록 가져올수 있도록 만듬 TreeItem - treeItem 생성메서드 만듬
```
{
"resultCode": "SUCCESS",
"data": {
"result": "SUCCESS",
"email": "blackduvet52@gmail.com",
"userId": 1,
"token": {
"accessToken": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIiwiYXV0aCI6IlJPTEVfVVNFUiIsInVzZXJJZCI6MSwiaWF0IjoxNzEwNjg1NDE2LCJleHAiOjE3MTA2ODcyMTZ9.qnFvAG-tffdzkcAxwSY-QnBcHNzI612-GkUqY24sS5M"
}
},
```
### TREE - userId를 CustomUserDetails에서 가져오게 수정 - service부분 modelmapper 대신 toentity로 수정
…값이 표시됨. if문으로 처리할 수 있겠지만 너무 길어진다....
TreeItem 수정 부분 뺴고 ModelMapper -> ToEntity()로 수정
개요:의존성 변경과 새로운 라이브러리 추가가 주요 변경 사항으로 나타났습니다. 또한 보안 설정 및 JWT 토큰 관련 설정이 업데이트되었으며, 사용자 정보 클래스 및 메서드 시그니처에 변화가 있었습니다. 상세 정보:
Uplevel your code reviews with CodeRabbit ProCodeRabbit ProIf you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects. |
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.
Files selected (38)
- build.gradle (2)
- src/main/java/com/chukapoka/server/common/authority/AppConfig.java (1)
- src/main/java/com/chukapoka/server/common/authority/SecurityConfig.java (1)
- src/main/java/com/chukapoka/server/common/authority/SwaggerConfig.java (1)
- src/main/java/com/chukapoka/server/common/authority/jwt/JwtAuthenticationFilter.java (3)
- src/main/java/com/chukapoka/server/common/authority/jwt/JwtTokenProvider.java (9)
- src/main/java/com/chukapoka/server/common/dto/CustomUser.java (1)
- src/main/java/com/chukapoka/server/common/dto/CustomUserDetails.java (1)
- src/main/java/com/chukapoka/server/common/dto/TokenDto.java (1)
- src/main/java/com/chukapoka/server/common/entity/Token.java (2)
- src/main/java/com/chukapoka/server/common/enums/TreeType.java (1)
- src/main/java/com/chukapoka/server/common/repository/TokenRepository.java (1)
- src/main/java/com/chukapoka/server/common/service/CustomUserDetailsService.java (2)
- src/main/java/com/chukapoka/server/tree/controller/TreeController.java (1)
- src/main/java/com/chukapoka/server/tree/dto/TreeCreateRequestDto.java (1)
- src/main/java/com/chukapoka/server/tree/dto/TreeDetailResponseDto.java (1)
- src/main/java/com/chukapoka/server/tree/dto/TreeList.java (1)
- src/main/java/com/chukapoka/server/tree/dto/TreeListResponseDto.java (1)
- src/main/java/com/chukapoka/server/tree/dto/TreeModifyRequestDto.java (1)
- src/main/java/com/chukapoka/server/tree/entity/Tree.java (1)
- src/main/java/com/chukapoka/server/tree/repository/TreeRepository.java (1)
- src/main/java/com/chukapoka/server/tree/service/TreeService.java (1)
- src/main/java/com/chukapoka/server/tree/service/TreeServiceImpl.java (1)
- src/main/java/com/chukapoka/server/treeItem/controller/TreeItemController.java (1)
- src/main/java/com/chukapoka/server/treeItem/dto/TreeItemCreateRequestDto.java (1)
- src/main/java/com/chukapoka/server/treeItem/dto/TreeItemDetailResponseDto.java (1)
- src/main/java/com/chukapoka/server/treeItem/dto/TreeItemListResponseDto.java (1)
- src/main/java/com/chukapoka/server/treeItem/dto/TreeItemModifyRequestDto.java (1)
- src/main/java/com/chukapoka/server/treeItem/entity/TreeItem.java (1)
- src/main/java/com/chukapoka/server/treeItem/repository/TreeItemRepository.java (1)
- src/main/java/com/chukapoka/server/treeItem/service/TreeItemService.java (1)
- src/main/java/com/chukapoka/server/treeItem/service/TreeItemServiceImpl.java (1)
- src/main/java/com/chukapoka/server/user/controller/HealthController.java (1)
- src/main/java/com/chukapoka/server/user/controller/UserController.java (2)
- src/main/java/com/chukapoka/server/user/dto/UserResponseDto.java (1)
- src/main/java/com/chukapoka/server/user/entity/User.java (1)
- src/main/java/com/chukapoka/server/user/repository/UserRepository.java (1)
- src/main/java/com/chukapoka/server/user/sevice/UserService.java (3)
Files ignored due to filter (3)
- screenshots/Oauth2.png
- src/main/resources/application.yaml
- swagger.yaml
Files skipped from review due to trivial changes (5)
- src/main/java/com/chukapoka/server/common/dto/CustomUser.java
- src/main/java/com/chukapoka/server/tree/dto/TreeListResponseDto.java
- src/main/java/com/chukapoka/server/treeItem/repository/TreeItemRepository.java
- src/main/java/com/chukapoka/server/user/controller/HealthController.java
- src/main/java/com/chukapoka/server/user/dto/UserResponseDto.java
Review comments generated (30)
- Review: 23
- LGTM: 7
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
|
|
||
| public static final String AUTHORIZATION_HEADER = "Authorization"; | ||
| public static final String BEARER_PREFIX = "Bearer"; | ||
|
|
||
| private final JwtTokenProvider jwtTokenProvider; | ||
| private final TokenRepository tokenRepository; |
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.
The import statement and package declaration seem to be incorrect. Please ensure that the package structure matches the directory structure.
- package com.chukapoka.server.common.authority;
+ package com.chukapoka.server.common.authority.jwt;
- import com.chukapoka.server.common.entity.Token;
+ import com.chukapoka.server.common.authority.jwt.JwtTokenProvider;| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { | ||
| // 1. Request Header 에서 토큰을 꺼냄 | ||
| String accessToken = resolveToken((HttpServletRequest) request); | ||
| // String data = tokenRepository.getAccessToken(token); | ||
| // System.out.println("data = " + data); | ||
| // 2. validateToken 으로 토큰 유효성 검사 | ||
| // 정상 토큰이면 해당 토큰으로 Authentication 을 가져와서 SecurityContext 에 저장 | ||
| if (StringUtils.hasText(accessToken)) { |
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.
build.gradle
Outdated
| runtimeOnly 'org.postgresql:postgresql' | ||
| // h2 | ||
| runtimeOnly 'com.h2database:h2' | ||
| // runtimeOnly 'com.h2database:h2' |
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.
| // modelmapper | ||
| implementation 'org.modelmapper:modelmapper:2.4.4' | ||
|
|
||
| // swagger3 | ||
| implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0' |
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.
| private String atExpiration; | ||
| private String rtExpiration; |
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.
The field names atExpiration and rtExpiration have been added in place of accessTokenExpiresIn. This change seems appropriate for specifying the expiration times for access tokens and refresh tokens.
- private Long accessTokenExpiresIn;
+ private String atExpiration;
+ private String rtExpiration;| /** 토큰 재발급(refresh token 유효한 상태) */ | ||
| @PostMapping("/reissue") | ||
| public BaseResponse<TokenResponseDto> reissue() { | ||
| long userId = ((CustomUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserId(); | ||
| long userId = ((CustomUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserId(); | ||
| TokenResponseDto tokenDto = userService.reissue(userId); | ||
| return new BaseResponse<>(ResultType.SUCCESS, tokenDto); | ||
| } |
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.
Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [22-22]
The casting from SecurityContextHolder.getContext().getAuthentication().getPrincipal() to CustomUserDetails seems incorrect. Please verify if this casting is necessary and ensure it aligns with the correct user details class.
- long userId = ((CustomUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserId();
+ long userId = ((CustomUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserId();---end_change_section---
---new_hunk---
71: long userId = ((CustomUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserId();
---old_hunk---
long userId = ((CustomUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserId();
| /** 토큰 재발급(refresh token 유효한 상태) */ | ||
| @PostMapping("/reissue") | ||
| public BaseResponse<TokenResponseDto> reissue() { | ||
| long userId = ((CustomUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserId(); | ||
| long userId = ((CustomUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserId(); | ||
| TokenResponseDto tokenDto = userService.reissue(userId); | ||
| return new BaseResponse<>(ResultType.SUCCESS, tokenDto); | ||
| } |
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.
Note: This review was outside of the patch, but no patch was found that overlapped with it. Original lines [31-31]
The casting from SecurityContextHolder.getContext().getAuthentication().getPrincipal() to CustomUserDetails appears to be inconsistent with the previous change. Please ensure consistency in the casting approach.
- long userId = ((CustomUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserId();
+ long userId = ((CustomUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUserId();---end_change_section---
|
|
||
|
|
||
|
|
||
| import com.chukapoka.server.common.authority.JwtTokenProvider; | ||
|
|
||
| import com.chukapoka.server.common.dto.CustomUser; | ||
| import com.chukapoka.server.common.authority.jwt.JwtTokenProvider; | ||
| import com.chukapoka.server.common.dto.CustomUserDetails; | ||
| import com.chukapoka.server.common.dto.TokenDto; | ||
| import com.chukapoka.server.common.dto.TokenResponseDto; | ||
| import com.chukapoka.server.common.entity.Token; |
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.
| new CustomUserDetails(user), | ||
| null, | ||
| List.of( |
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.
| .atExpiration(jwtToken.getAtExpiration()) | ||
| .rtExpiration(jwtToken.getRtExpiration()) |
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.
Issues 번호 :
Closes #31
변경, 추가된 코드(설명 등)
User , Tree TreeItem + jwt-version #28 에 추가
Swagger-ui 접속
회원가입 테스트
오류
h2 로그인시 오류
오류해결
https://stackoverflow.com/questions/65894268/how-does-headers-frameoptions-disable-work
.headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin))h2 요소를 사용 비활성화시킴