File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed
src/main/java/dmu/dasom/api
domain/executive/controller Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change 88import jakarta .validation .constraints .Min ;
99import lombok .RequiredArgsConstructor ;
1010import org .springframework .http .ResponseEntity ;
11+ import org .springframework .security .access .prepost .PreAuthorize ;
1112import org .springframework .web .bind .annotation .*;
1213
1314import java .util .List ;
@@ -33,12 +34,14 @@ public ResponseEntity<List<ExecutiveListResponseDto>> getAllExecutives() {
3334 }
3435
3536 @ Operation (summary = "임원진 생성" )
37+ @ PreAuthorize ("hasRole('ADMIN')" )
3638 @ PostMapping
3739 public ResponseEntity <ExecutiveCreationResponseDto > createExecutive (@ Valid @ RequestBody ExecutiveRequestDto requestDto ) {
3840 return ResponseEntity .status (201 ).body (executiveService .createExecutive (requestDto ));
3941 }
4042
4143 @ Operation (summary = "임원진 삭제" )
44+ @ PreAuthorize ("hasRole('ADMIN')" )
4245 @ DeleteMapping ("/{id}" )
4346 // Void 사용 이유?
4447 // DELETE 요청 같이 성공/실패만 확인하면 되는 경우 사용
@@ -48,6 +51,7 @@ public ResponseEntity<Void> deleteExecutive(@PathVariable @Min(1) Long id) {
4851 }
4952
5053 @ Operation (summary = "임원진 수정" )
54+ @ PreAuthorize ("hasRole('ADMIN')" )
5155 @ PutMapping ("/{id}" )
5256 public ResponseEntity <ExecutiveResponseDto > updateExecutive (@ PathVariable @ Min (1 ) Long id ,
5357 @ Valid @ RequestBody ExecutiveUpdateRequestDto requestDto ) {
Original file line number Diff line number Diff line change 1212import org .springframework .context .annotation .Configuration ;
1313import org .springframework .security .authentication .AuthenticationManager ;
1414import org .springframework .security .config .annotation .authentication .configuration .AuthenticationConfiguration ;
15+ import org .springframework .security .config .annotation .method .configuration .EnableMethodSecurity ;
1516import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
1617import org .springframework .security .config .annotation .web .configuration .EnableWebSecurity ;
1718import org .springframework .security .config .annotation .web .configurers .AbstractHttpConfigurer ;
2627
2728@ Configuration
2829@ EnableWebSecurity
30+ @ EnableMethodSecurity (prePostEnabled = true ) // 메소드 보안 활성화 (@PreAuthorize 사용)
2931@ RequiredArgsConstructor
3032public class SecurityConfig {
3133
You can’t perform that action at this time.
0 commit comments