[Feat] 켐페인 보낸 제안 조회#118
Conversation
Summary of ChangesHello @ParkJiYeoung8297, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 사용자가 보낸 캠페인 제안의 상세 정보를 조회하는 기능을 추가합니다. 새로운 서비스 계층과 API 엔드포인트를 도입하여 특정 캠페인 제안의 모든 관련 정보(예: 콘텐츠 태그, 제안 상태)를 효율적으로 검색하고 반환할 수 있도록 합니다. 이는 사용자 경험을 개선하고 제안 관리의 투명성을 높이는 데 기여합니다. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
이번 PR은 캠페인 제안 상세 조회 기능을 추가하는 변경사항을 담고 있습니다. 전반적으로 새로운 기능이 잘 구현되었지만, 한 가지 중요한 보안 이슈가 발견되었습니다. 인증된 사용자가 ID만 알면 다른 사용자의 제안 정보를 조회할 수 있는 권한 문제가 있습니다. 이를 해결하기 위한 제안을 리뷰 코멘트로 남겼습니다. 또한, 이와 관련하여 필요한 에러 코드 추가에 대한 제안도 포함했습니다. 해당 부분들을 수정하여 API의 보안을 강화하는 것이 좋겠습니다.
| CampaignProposal proposal = campaignProposalRepository.findByIdWithTags(proposalId) | ||
| .orElseThrow(() -> new CustomException(BusinessErrorCode.CAMPAIGN_PROPOSAL_NOT_FOUND)); | ||
|
|
||
| return CampaignProposalDetailResponse.from(proposal); |
There was a problem hiding this comment.
userId 파라미터가 사용되지 않고 있어, 인증된 사용자가 다른 사용자의 제안 정보를 조회할 수 있는 보안 취약점이 있습니다. 제안을 조회하기 전에 현재 사용자가 해당 제안(creator 또는 brand 소속)에 접근할 권한이 있는지 확인하는 로직을 추가해야 합니다. BusinessErrorCode에 제안한 PROPOSAL_ACCESS_FORBIDDEN 에러 코드를 사용하여 권한이 없는 경우 예외를 발생시키는 것을 권장합니다.
CampaignProposal proposal = campaignProposalRepository.findByIdWithTags(proposalId)
.orElseThrow(() -> new CustomException(BusinessErrorCode.CAMPAIGN_PROPOSAL_NOT_FOUND));
Long creatorId = proposal.getCreator().getId();
Long brandUserId = (proposal.getBrand().getUser() != null) ? proposal.getBrand().getUser().getId() : null;
if (!userId.equals(creatorId) && !userId.equals(brandUserId)) {
throw new CustomException(BusinessErrorCode.PROPOSAL_ACCESS_FORBIDDEN);
}
return CampaignProposalDetailResponse.from(proposal);| CAMPAIGN_APPLY_ALREADY_APPLIED(HttpStatus.BAD_REQUEST, "CAMPAIGN_400_1", "이미 지원한 캠페인입니다."); | ||
| CAMPAIGN_APPLY_ALREADY_APPLIED(HttpStatus.BAD_REQUEST, "CAMPAIGN_400_1", "이미 지원한 캠페인입니다."), | ||
|
|
||
| CAMPAIGN_PROPOSAL_NOT_FOUND(HttpStatus.NOT_FOUND, "CAMPAIGN_404_1", "캠페인 지원 내역이 없습니다."); |
There was a problem hiding this comment.
제안 상세 조회 시 권한이 없는 사용자의 접근을 막기 위한 에러 코드를 추가하는 것이 좋습니다. CampaignProposalQueryService에서 권한 검사를 추가할 때 이 에러 코드를 사용할 수 있습니다.
| CAMPAIGN_PROPOSAL_NOT_FOUND(HttpStatus.NOT_FOUND, "CAMPAIGN_404_1", "캠페인 지원 내역이 없습니다."); | |
| CAMPAIGN_PROPOSAL_NOT_FOUND(HttpStatus.NOT_FOUND, "CAMPAIGN_404_1", "캠페인 지원 내역이 없습니다."), | |
| PROPOSAL_ACCESS_FORBIDDEN(HttpStatus.FORBIDDEN, "PROPOSAL_403_1", "해당 제안에 접근할 권한이 없습니다."); |
Summary
캠페인 보낸 제안 조회 기능 추가
Changes
Type of Change
Related Issues
#53
참고 사항
아직 사용자 확인과 같은 권한 예외처리가 필요합니다.