-
Notifications
You must be signed in to change notification settings - Fork 0
Bug/#66 #67
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
Bug/#66 #67
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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
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
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
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
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 |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| import java.io.IOException; | ||
| import java.nio.charset.StandardCharsets; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/assignments") | ||
|
|
@@ -40,12 +41,12 @@ public class AssignmentCommandController { | |
| // 과제 단일 조회 | ||
| @GetMapping("/{assignmentId}") | ||
| public ResponseEntity<AssignmentResponseDto> getAssignment( | ||
| @CurrentUser Long userId, | ||
| @PathVariable Long assignmentId | ||
| @CurrentUser UUID userId, | ||
| @PathVariable UUID assignmentId | ||
| ) { | ||
| AssignmentResponseDto result = assignmentCommandService.findById(assignmentId); | ||
| Assignment assignment = assignmentCommandService.findByIdOrThrow(assignmentId); | ||
| Long classroomId = assignment.getClassRoom().getClassRoomId(); | ||
| UUID classroomId = assignment.getClassRoom().getClassRoomId(); | ||
| if (!classroomUserService.isUserInClassroom(classroomId, userId)) { | ||
| throw new AccessDeniedException("해당 수업실에 속하지 않은 유저입니다."); | ||
| } | ||
|
|
@@ -55,8 +56,8 @@ public ResponseEntity<AssignmentResponseDto> getAssignment( | |
| // 교실 과제 전체 조회 | ||
| @GetMapping("/{classId}/all") | ||
| public ResponseEntity<List<AssignmentResponseDto>> getAllClassroomAssignment( | ||
| @CurrentUser Long userId, | ||
| @PathVariable Long classId | ||
| @CurrentUser UUID userId, | ||
| @PathVariable UUID classId | ||
| ) { | ||
| List<AssignmentResponseDto> result = assignmentCommandService.findAllById(userId,classId); | ||
|
|
||
|
|
@@ -69,23 +70,23 @@ public ResponseEntity<List<AssignmentResponseDto>> getAllClassroomAssignment( | |
|
|
||
| // 메인 페이지 모든 과제 조회 | ||
| @GetMapping("/me") | ||
| public ResponseEntity<List<GetAllAssignmentDto>> getAllAssignments(@CurrentUser Long userId) { | ||
| public ResponseEntity<List<GetAllAssignmentDto>> getAllAssignments(@CurrentUser UUID userId) { | ||
| List<GetAllAssignmentDto> result = assignmentCommandService.findAllAssignmentMe(userId); | ||
| return ResponseEntity.ok(result); | ||
| } | ||
|
|
||
| // 첨부 파일 혹은 링크 전체 조회 (선생, 학생) | ||
| @GetMapping("/{submissionId}/attachment") | ||
| public ResponseEntity<List<SubmissionAttachmentDto>> findAllAssignments(@CurrentUser Long userId, @PathVariable Long submissionId) { | ||
| public ResponseEntity<List<SubmissionAttachmentDto>> findAllAssignments(@CurrentUser UUID userId, @PathVariable UUID submissionId) { | ||
| List<SubmissionAttachmentDto> result = submissionCommandService.findAllAssignment(submissionId); | ||
| return ResponseEntity.ok(result); | ||
| } | ||
|
Comment on lines
78
to
83
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. 제출물 첨부 조회 엔드포인트에 인가 검증이 누락되어 있습니다 현재 사용자 검증 없이 제출물 첨부 목록을 노출합니다. 수업 멤버 또는 적법한 당사자(담당 교사/제출자)만 접근 가능하도록 확인 후 조회하세요. 예시 수정안: @GetMapping("/{submissionId}/attachment")
- public ResponseEntity<List<SubmissionAttachmentDto>> findAllAssignments(@CurrentUser UUID userId, @PathVariable UUID submissionId) {
- List<SubmissionAttachmentDto> result = submissionCommandService.findAllAssignment(submissionId);
+ public ResponseEntity<List<SubmissionAttachmentDto>> findAllAssignments(@CurrentUser UUID userId,
+ @PathVariable UUID submissionId) {
+ var submission = submissionCommandService.findByIdOrThrow(submissionId);
+ UUID classroomId = submission.getAssignment().getClassRoom().getClassRoomId();
+ if (!classroomUserService.isUserInClassroom(classroomId, userId)) {
+ throw new AccessDeniedException("해당 수업실에 속하지 않은 유저입니다.");
+ }
+ List<SubmissionAttachmentDto> result = submissionCommandService.findAllAssignment(submissionId);
return ResponseEntity.ok(result);
}추가 import 필요: import hello.cluebackend.domain.submission.domain.Submission;또한 메서드명 |
||
|
|
||
| // 첨부 파일 다운로드 | ||
| @GetMapping("/{assignmentAttachmentId}/download") | ||
| public ResponseEntity<Resource> assignmentAttachmentDownload( | ||
| @CurrentUser Long userId, | ||
| @PathVariable Long assignmentAttachmentId | ||
| @CurrentUser UUID userId, | ||
| @PathVariable UUID assignmentAttachmentId | ||
| ) throws IOException { | ||
| AssignmentAttachment assignmentAttachment = assignmentCommandService.findAssignmentAttachmentByIdOrderThrow(assignmentAttachmentId); | ||
| Resource resource = assignmentCommandService.downloadAttachment(assignmentAttachment); | ||
|
|
||
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
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
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
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.
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.
🛠️ Refactor suggestion
인가(권한) 검증을 데이터 조회보다 먼저 수행하세요
DTO 조회를 먼저 수행하면 불필요한 DB 접근 및 정보 노출 가능성이 있습니다. 아래처럼 순서를 바꾸세요.
📝 Committable suggestion
🤖 Prompt for AI Agents