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

[DDING-000] 폼지 지원자 조회시 권한 검증로직 추가 #266

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

KoSeonJe
Copy link
Collaborator

@KoSeonJe KoSeonJe commented Feb 13, 2025

🚀 작업 내용

폼지 지원자 정보는 중요 정보이기에 조회시 권한 검증로직 추가하였습니다

🤔 고민했던 내용

💬 리뷰 중점사항

Summary by CodeRabbit

  • New Features
    • 양식 조회 시 사용자 소속을 확인하여, 권한이 없는 접근을 안전하게 차단하는 보안 검증 로직이 강화되었습니다.

Copy link

coderabbitai bot commented Feb 13, 2025

Caution

Review failed

The pull request is closed.

"""

워크스루

이번 PR은 FacadeCentralFormApplicationServiceImpl 클래스에 새로운 의존성인 ClubService를 추가하고, 양식 신청 조회 메소드인 getAllFormApplicationgetFormApplication에 사용자 권한 검증 로직을 도입합니다. 검증은 사용자의 클럽 정보와 양식에 연결된 클럽 정보를 비교하여, 불일치 시 AuthenticationException.NonHaveAuthority 예외를 발생시킵니다. 또한, 기존의 null 체크 로직이 제거되고, 권한 검증을 위한 새로운 private 메소드 validateAuthority가 추가되었습니다.

변경 사항

파일 경로 변경 사항 요약
src/main/.../FacadeCentralFormApplicationServiceImpl.java - ClubService 의존성 추가
- getAllFormApplicationgetFormApplication 메소드에 validateAuthority 로직 추가
- 기존의 null 체크 제거
- private 메소드 validateAuthority 도입

시퀀스 다이어그램

sequenceDiagram
    participant 사용자
    participant 서비스 as FacadeCentralFormApplicationServiceImpl
    participant ClubService
    participant 양식 as Form

    사용자->>서비스: 요청(getAllFormApplication / getFormApplication)
    서비스->>ClubService: 사용자 ID로 클럽 조회 요청
    ClubService-->>서비스: 클럽 정보 반환
    서비스->>서비스: validateAuthority(club, form) 호출
    alt 권한 일치
      서비스-->>사용자: 양식 신청 정보 반환
    else 권한 불일치
      서비스-->>사용자: AuthenticationException.NonHaveAuthority 예외 발생
    end
Loading

관련 PR

제안된 라벨

🚨긴급, 🛠️버그, D-0

제안된 리뷰어

  • wonjunYou
  • 5uhwann
    """

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d6d25c and 4a87f55.

📒 Files selected for processing (1)
  • src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/FacadeCentralFormApplicationServiceImpl.java (5 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/FacadeCentralFormApplicationServiceImpl.java (2)

39-50: 권한 검증 로직의 에러 메시지를 더 구체적으로 개선하면 좋겠습니다.

현재 구현은 적절하나, 사용자 경험 향상을 위해 다음 사항을 고려해보세요:

  1. 권한 오류 발생 시 더 구체적인 에러 메시지 제공
  2. 로깅 추가로 권한 검증 실패 추적

예시 코드:

 @Override
 public MyAllFormApplicationsQuery getAllFormApplication(Long formId, User user) {
     Club club = clubService.getByUserId(user.getId());
     Form form = formService.getById(formId);
-    validateAuthority(club, form);
+    validateAuthority(club, form, 
+        String.format("사용자의 클럽(%s)이 폼의 클럽(%s)과 일치하지 않습니다", 
+            club.getName(), form.getClub().getName()));
     List<FormApplication> formApplications = formApplicationService.getAllByForm(form);
     // ... 나머지 코드
 }

78-82: 권한 검증 메소드의 방어적 프로그래밍을 강화하면 좋겠습니다.

현재 구현은 기본적인 기능은 충족하지만, 다음과 같은 개선사항을 고려해보세요:

  1. null 체크 추가
  2. 로깅 추가
  3. 구체적인 에러 메시지 파라미터화
-private void validateAuthority(Club club, Form form) {
+private void validateAuthority(Club club, Form form, String errorMessage) {
+    Objects.requireNonNull(club, "클럽 정보가 없습니다");
+    Objects.requireNonNull(form, "폼 정보가 없습니다");
+    Objects.requireNonNull(form.getClub(), "폼의 클럽 정보가 없습니다");
+
     if (!Objects.equals(club.getId(), form.getClub().getId())) {
-        throw new NonHaveAuthority();
+        log.warn("권한 검증 실패: {}", errorMessage);
+        throw new NonHaveAuthority(errorMessage);
     }
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5b70d9 and 2d6d25c.

📒 Files selected for processing (1)
  • src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/FacadeCentralFormApplicationServiceImpl.java (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and analyze
🔇 Additional comments (2)
src/main/java/ddingdong/ddingdongBE/domain/formapplication/service/FacadeCentralFormApplicationServiceImpl.java (2)

3-5: 새로운 의존성 추가가 적절합니다!

권한 검증을 위한 새로운 의존성들이 잘 추가되었습니다. ClubService를 통한 사용자의 클럽 정보 조회는 권한 검증에 필수적인 요소입니다.

Also applies to: 21-21, 37-37


52-61: 권한 검증 패턴이 일관성 있게 적용되었습니다.

getAllFormApplication과 동일한 패턴으로 권한 검증이 구현되어 있어 코드의 일관성이 잘 유지되었습니다. 다만, 이 메소드에도 위에서 제안한 동일한 에러 메시지 개선사항을 적용하면 좋겠습니다.

Copy link
Collaborator

@Seooooo24 Seooooo24 left a comment

Choose a reason for hiding this comment

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

확인했습니다 고생하셨습니다!

@Seooooo24 Seooooo24 merged commit 27ba021 into develop Feb 13, 2025
0 of 2 checks passed
@Seooooo24 Seooooo24 deleted the feature/DDING-001 branch February 13, 2025 17:54
@KoSeonJe KoSeonJe self-assigned this Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants