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

Spring Security 인증/인가 구조 개편 및 GUEST 로그인 도입 완료 #456

Merged
merged 11 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ gradle/
/src/main/resources/*.yml
!/src/main/resources/application.yml
src/main/java/page/clab/api/global/auth/application/DataLoader.java
src/main/java/page/clab/api/global/auth/service/DataLoader.java
src/main/java/page/clab/api/global/auth/application/MemberFactory.java
src/main/java/page/clab/api/global/config/SecurityProperties.java
/config/whitelist.json

Expand Down Expand Up @@ -45,4 +45,4 @@ out/
.vscode/

### Environments ###
.env
.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
Expand Down Expand Up @@ -43,7 +43,7 @@ public class ActivityGroupAdminController {
private final PageableUtils pageableUtils;

@Operation(summary = "[U] 활동 생성", description = "ROLE_USER 이상의 권한이 필요함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@PostMapping("")
public ApiResponse<Long> createActivityGroup(
@Valid @RequestBody ActivityGroupRequestDto requestDto
Expand All @@ -53,7 +53,7 @@ public ApiResponse<Long> createActivityGroup(
}

@Operation(summary = "[U] 활동 수정", description = "ROLE_USER 이상의 권한이 필요함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@PatchMapping("/{activityGroupId}")
public ApiResponse<Long> updateActivityGroup(
@PathVariable(name = "activityGroupId") Long activityGroupId,
Expand All @@ -64,7 +64,7 @@ public ApiResponse<Long> updateActivityGroup(
}

@Operation(summary = "[A] 활동 상태 변경", description = "ROLE_ADMIN 이상의 권한이 필요함")
@Secured({ "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('ADMIN')")
@PatchMapping("manage/{activityGroupId}")
public ApiResponse<Long> manageActivityGroupStatus(
@PathVariable(name = "activityGroupId") Long activityGroupId,
Expand All @@ -75,7 +75,7 @@ public ApiResponse<Long> manageActivityGroupStatus(
}

@Operation(summary = "[A] 활동 삭제", description = "ROLE_ADMIN 이상의 권한이 필요함")
@Secured({ "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('ADMIN')")
@DeleteMapping("/{activityGroupId}")
public ApiResponse<Long> deleteActivityGroup(
@PathVariable(name = "activityGroupId") Long activityGroupId
Expand All @@ -86,7 +86,7 @@ public ApiResponse<Long> deleteActivityGroup(

@Operation(summary = "[U] 프로젝트 진행도 수정", description = "ROLE_USER 이상의 권한이 필요함<br>" +
"진행도는 0~100 사이의 값으로 입력해야 함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@PatchMapping("/progress/{activityGroupId}")
public ApiResponse<Long> updateProjectProgress(
@PathVariable(name = "activityGroupId") Long activityGroupId,
Expand All @@ -97,7 +97,7 @@ public ApiResponse<Long> updateProjectProgress(
}

@Operation(summary = "[U] 커리큘럼 및 일정 생성", description = "ROLE_USER 이상의 권한이 필요함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@PostMapping("/schedule")
public ApiResponse<Long> addSchedule(
@RequestParam(name = "activityGroupId") Long activityGroupId,
Expand All @@ -110,7 +110,7 @@ public ApiResponse<Long> addSchedule(
@Operation(summary = "[U] 활동 멤버 및 지원서 조회", description = "ROLE_USER 이상의 권한이 필요함<br>" +
"관리자 또는 리더만 조회 가능<br>" +
"DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@GetMapping("/members")
public ApiResponse<PagedResponseDto<ActivityGroupMemberWithApplyReasonResponseDto>> getApplyGroupMemberList(
@RequestParam(name = "activityGroupId") Long activityGroupId,
Expand All @@ -125,7 +125,7 @@ public ApiResponse<PagedResponseDto<ActivityGroupMemberWithApplyReasonResponseDt
}

@Operation(summary = "[U] 신청 멤버 상태 변경", description = "ROLE_USER 이상의 권한이 필요함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@PatchMapping("/accept")
public ApiResponse<String> acceptGroupMember(
@RequestParam(name = "activityGroupId") Long activityGroupId,
Expand All @@ -138,7 +138,7 @@ public ApiResponse<String> acceptGroupMember(

@GetMapping("/deleted")
@Operation(summary = "[S] 삭제된 활동그룹 조회하기", description = "ROLE_SUPER 이상의 권한이 필요함")
@Secured({ "ROLE_SUPER" })
@PreAuthorize("hasRole('SUPER')")
public ApiResponse<PagedResponseDto<ActivityGroupResponseDto>> getDeletedActivityGroups(
@RequestParam(name = "page", defaultValue = "0") int page,
@RequestParam(name = "size", defaultValue = "20") int size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
Expand Down Expand Up @@ -48,7 +48,7 @@ public class ActivityGroupBoardController {
"제출 : 부모 게시판(과제), 첨부파일 경로 리스트<br>" +
"피드백 : 부모 게시판(제출), 카테고리, 내용 , 첨부파일 경로 리스트(선택)"
)
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@PostMapping("")
public ApiResponse<Long> createActivityGroupBoard(
@RequestParam(name = "parentId", required = false) Long parentId,
Expand All @@ -61,7 +61,7 @@ public ApiResponse<Long> createActivityGroupBoard(

@Operation(summary = "[U] 활동 그룹 게시판 조회", description = "ROLE_USER 이상의 권한이 필요함<br>" +
"DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@GetMapping("/list")
public ApiResponse<PagedResponseDto<ActivityGroupBoardResponseDto>> getActivityGroupBoardList(
@RequestParam(name = "page", defaultValue = "0") int page,
Expand All @@ -75,7 +75,7 @@ public ApiResponse<PagedResponseDto<ActivityGroupBoardResponseDto>> getActivityG
}

@Operation(summary = "[U] 활동 그룹 게시판 단일 조회", description = "ROLE_USER 이상의 권한이 필요함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@GetMapping("")
public ApiResponse<ActivityGroupBoardResponseDto> getActivityGroupBoardById(
@RequestParam(name = "activityGroupBoardId") Long activityGroupBoardId
Expand All @@ -86,7 +86,7 @@ public ApiResponse<ActivityGroupBoardResponseDto> getActivityGroupBoardById(

@Operation(summary = "[U] 활동 그룹 ID에 대한 카테고리별 게시판 조회", description = "ROLE_USER 이상의 권한이 필요함<br>" +
"DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@GetMapping("/by-category")
public ApiResponse<PagedResponseDto<ActivityGroupBoardResponseDto>> getActivityGroupBoardByCategory(
@RequestParam(name = "activityGroupId") Long activityGroupId,
Expand All @@ -102,7 +102,7 @@ public ApiResponse<PagedResponseDto<ActivityGroupBoardResponseDto>> getActivityG
}

@Operation(summary = "[U] 활동 그룹 게시판 계층 구조적 조회, 부모 및 자식 게시판 함께 반환", description = "ROLE_USER 이상의 권한이 필요함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@GetMapping("/by-parent")
public ApiResponse<PagedResponseDto<ActivityGroupBoardChildResponseDto>> getActivityGroupBoardByParent(
@RequestParam(name = "parentId") Long parentId,
Expand All @@ -115,7 +115,7 @@ public ApiResponse<PagedResponseDto<ActivityGroupBoardChildResponseDto>> getActi
}

@Operation(summary = "[U] 나의 제출 과제 및 피드백 조회", description = "ROLE_USER 이상의 권한이 필요함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@GetMapping("/my-assignment")
public ApiResponse<List<AssignmentSubmissionWithFeedbackResponseDto>> getMyAssignmentBoardWithFeedback(
@RequestParam(name = "parentId") Long parentId
Expand All @@ -125,7 +125,7 @@ public ApiResponse<List<AssignmentSubmissionWithFeedbackResponseDto>> getMyAssig
}

@Operation(summary = "[U] 활동 그룹 게시판 수정", description = "ROLE_USER 이상의 권한이 필요함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@PatchMapping("")
public ApiResponse<ActivityGroupBoardUpdateResponseDto> updateActivityGroupBoard(
@RequestParam(name = "activityGroupBoardId") Long activityGroupBoardId,
Expand All @@ -136,7 +136,7 @@ public ApiResponse<ActivityGroupBoardUpdateResponseDto> updateActivityGroupBoard
}

@Operation(summary = "[U] 활동 그룹 게시판 삭제", description = "ROLE_USER 이상의 권한이 필요함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@DeleteMapping("")
public ApiResponse<Long> deleteActivityGroupBoard(
@RequestParam Long activityGroupBoardId
Expand All @@ -145,9 +145,9 @@ public ApiResponse<Long> deleteActivityGroupBoard(
return ApiResponse.success(id);
}

@GetMapping("/deleted")
@Operation(summary = "[S] 삭제된 활동 그룹 게시판 조회하기", description = "ROLE_SUPER 이상의 권한이 필요함")
@Secured({ "ROLE_SUPER" })
@PreAuthorize("hasRole('SUPER')")
@GetMapping("/deleted")
public ApiResponse<PagedResponseDto<ActivityGroupBoardResponseDto>> getDeletedActivityGroupBoards(
@RequestParam(name = "page", defaultValue = "0") int page,
@RequestParam(name = "size", defaultValue = "20") int size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -39,8 +39,9 @@ public class ActivityGroupMemberController {
private final ActivityGroupMemberService activityGroupMemberService;
private final PageableUtils pageableUtils;

@Operation(summary = "활동 전체 목록 조회", description = "ROLE_ANONYMOUS 이상의 권한이 필요함<br>" +
@Operation(summary = "[G] 활동 전체 목록 조회", description = "ROLE_GUEST 이상의 권한이 필요함<br>" +
"DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함")
@PreAuthorize("hasRole('GUEST')")
@GetMapping("")
public ApiResponse<PagedResponseDto<ActivityGroupResponseDto>> getActivityGroups(
@RequestParam(name = "page", defaultValue = "0") int page,
Expand All @@ -53,7 +54,8 @@ public ApiResponse<PagedResponseDto<ActivityGroupResponseDto>> getActivityGroups
return ApiResponse.success(activityGroups);
}

@Operation(summary = "활동 상세 조회", description = "ROLE_ANONYMOUS 이상의 권한이 필요함")
@Operation(summary = "[U] 활동 상세 조회", description = "ROLE_ANONYMOUS 이상의 권한이 필요함")
@PreAuthorize("hasRole('USER')")
@GetMapping("/{activityGroupId}")
public ApiResponse<Object> getActivityGroup(
@PathVariable(name = "activityGroupId") Long activityGroupId
Expand All @@ -62,8 +64,8 @@ public ApiResponse<Object> getActivityGroup(
return ApiResponse.success(activityGroup);
}

@Operation(summary = "[U] 나의 활동 목록 조회", description = "ROLE_USER 이상의 권한이 필요함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@Operation(summary = "[G] 나의 활동 목록 조회", description = "ROLE_GUEST 이상의 권한이 필요함")
@PreAuthorize("hasRole('GUEST')")
@GetMapping("/my")
public ApiResponse<PagedResponseDto<ActivityGroupResponseDto>> getMyActivityGroups(
@RequestParam(name = "page", defaultValue = "0") int page,
Expand All @@ -75,7 +77,7 @@ public ApiResponse<PagedResponseDto<ActivityGroupResponseDto>> getMyActivityGrou
}

@Operation(summary = "[U] 활동 상태별 조회", description = "ROLE_USER 이상의 권한이 필요함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@GetMapping("/status")
public ApiResponse<PagedResponseDto<ActivityGroupStatusResponseDto>> getActivityGroupsByStatus(
@RequestParam(name = "activityGroupStatus") ActivityGroupStatus status,
Expand All @@ -87,8 +89,9 @@ public ApiResponse<PagedResponseDto<ActivityGroupStatusResponseDto>> getActivity
return ApiResponse.success(activityGroups);
}

@Operation(summary = "카테고리별 활동 목록 조회", description = "ROLE_ANONYMOUS 이상의 권한이 필요함<br>" +
@Operation(summary = "[G] 카테고리별 활동 목록 조회", description = "ROLE_GUEST 이상의 권한이 필요함<br>" +
"DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함")
@PreAuthorize("hasRole('GUEST')")
@GetMapping("/list")
public ApiResponse<PagedResponseDto<ActivityGroupResponseDto>> getActivityGroupsByCategory(
@RequestParam(name = "category") ActivityGroupCategory category,
Expand All @@ -102,9 +105,9 @@ public ApiResponse<PagedResponseDto<ActivityGroupResponseDto>> getActivityGroups
return ApiResponse.success(activityGroups);
}

@Operation(summary = "[U] 활동 일정 조회", description = "ROLE_USER 이상의 권한이 필요함<br>" +
@Operation(summary = "[G] 활동 일정 조회", description = "ROLE_GUEST 이상의 권한이 필요함<br>" +
"DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('GUEST')")
@GetMapping("/schedule")
public ApiResponse<PagedResponseDto<GroupScheduleDto>> getGroupScheduleList(
@RequestParam(name = "activityGroupId") Long activityGroupId,
Expand All @@ -121,7 +124,7 @@ public ApiResponse<PagedResponseDto<GroupScheduleDto>> getGroupScheduleList(
@Operation(summary = "[U] 활동 멤버 조회", description = "ROLE_USER 이상의 권한이 필요함<br>" +
"활동에 참여(수락)된 멤버만 조회 가능<br>" +
"DTO의 필드명을 기준으로 정렬 가능하며, 정렬 방향은 오름차순(asc)과 내림차순(desc)이 가능함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@GetMapping("/members")
public ApiResponse<PagedResponseDto<GroupMemberResponseDto>> getActivityGroupMemberList(
@RequestParam(name = "activityGroupId") Long activityGroupId,
Expand All @@ -136,7 +139,7 @@ public ApiResponse<PagedResponseDto<GroupMemberResponseDto>> getActivityGroupMem
}

@Operation(summary = "[U] 활동 신청", description = "ROLE_USER 이상의 권한이 필요함")
@Secured({ "ROLE_USER", "ROLE_ADMIN", "ROLE_SUPER" })
@PreAuthorize("hasRole('USER')")
@PostMapping("/apply")
public ApiResponse<Long> applyActivityGroup(
@RequestParam Long activityGroupId,
Expand Down
Loading