Skip to content

Commit ce8978d

Browse files
authored
Merge pull request #55 from DMU-DebugVisual/fix/comment-notification
fix: NotificationController Swagger 보안 요구 사항 충돌 해결(#54)
2 parents 8319e4b + 50e111d commit ce8978d

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/main/java/com/dmu/debug_visual/community/controller/NotificationController.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
@RestController
2626
@RequestMapping("/api/notifications")
2727
@RequiredArgsConstructor
28-
@Tag(name = "알림 API", description = "사용자 알림 조회 및 읽음 처리 API") // 태그 이름에 이모지 추가
29-
@SecurityRequirement(name = "bearerAuth") // 모든 API에 JWT 인증 필요 명시
28+
@Tag(name = "알림 API", description = "사용자 알림 조회 및 읽음 처리 API")
3029
public class NotificationController {
3130

3231
private final NotificationService notificationService;
@@ -69,7 +68,7 @@ public ResponseEntity<List<NotificationResponse>> getMyNotifications(
6968
@ApiResponse(responseCode = "403", description = "접근 권한 없음 (본인 알림 아님)", content = @Content),
7069
@ApiResponse(responseCode = "404", description = "해당 ID의 알림 없음", content = @Content)
7170
})
72-
public ResponseEntity<Void> markAsRead( // 반환 타입 void 대신 ResponseEntity<Void> 사용
71+
public ResponseEntity<Void> markAsRead(
7372
@Parameter(description = "읽음 처리할 알림 ID", required = true, example = "1")
7473
@PathVariable Long id,
7574
@Parameter(hidden = true) // Swagger UI에서 파라미터 숨김 처리

src/main/java/com/dmu/debug_visual/config/SecurityConfig.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,15 @@ public SecurityFilterChain devSecurityFilterChain(HttpSecurity http) throws Exce
5454
.requestMatchers("/swagger-ui/**", "/v3/api-docs/**").permitAll()
5555
.requestMatchers("/api/users/login", "/api/users/signup").permitAll()
5656
.requestMatchers("/api/code/**").permitAll()
57-
// ★ (유지) GET 요청은 누구나 접근 가능
5857
.requestMatchers(HttpMethod.GET, "/api/posts/**", "/api/comments/**").permitAll()
5958

6059
// 2. USER 또는 ADMIN 권한이 필요한 경로
61-
// ★ (수정) POST, PUT, DELETE 등 GET 외의 메서드는 USER 또는 ADMIN 권한 필요
6260
.requestMatchers(HttpMethod.POST, "/api/posts/**", "/api/comments/**", "/api/notifications/**").hasAnyRole("USER", "ADMIN")
6361
.requestMatchers(HttpMethod.PUT, "/api/posts/**", "/api/comments/**", "/api/notifications/**").hasAnyRole("USER", "ADMIN")
6462
.requestMatchers(HttpMethod.DELETE, "/api/posts/**", "/api/comments/**", "/api/notifications/**").hasAnyRole("USER", "ADMIN")
6563
.requestMatchers(HttpMethod.PATCH, "/api/posts/**", "/api/comments/**", "/api/notifications/**").hasAnyRole("USER", "ADMIN")
64+
.requestMatchers(HttpMethod.GET, "/api/notifications/**").hasAnyRole("USER", "ADMIN")
6665

67-
// ★ (수정) GET을 제외한 나머지 /api/notifications/** 경로는 여기서 처리됩니다.
68-
.requestMatchers("/api/notifications/**").hasAnyRole("USER", "ADMIN")
6966
.requestMatchers("/api/report/**").hasAnyRole("USER", "ADMIN")
7067
.requestMatchers("/api/files/**").hasAnyRole("USER", "ADMIN")
7168
.requestMatchers("/api/collab").hasAnyRole("USER", "ADMIN")
@@ -103,14 +100,13 @@ public SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws
103100
.requestMatchers("/api/admin/**").hasRole("ADMIN")
104101

105102
// 3. USER 또는 ADMIN 권한이 필요한 경로
106-
// ★ (수정) POST, PUT, DELETE 등 GET 외의 메서드는 USER 또는 ADMIN 권한 필요
107103
.requestMatchers(HttpMethod.POST, "/api/posts/**", "/api/comments/**", "/api/notifications/**").hasAnyRole("USER", "ADMIN")
108104
.requestMatchers(HttpMethod.PUT, "/api/posts/**", "/api/comments/**", "/api/notifications/**").hasAnyRole("USER", "ADMIN")
109105
.requestMatchers(HttpMethod.DELETE, "/api/posts/**", "/api/comments/**", "/api/notifications/**").hasAnyRole("USER", "ADMIN")
110-
.requestMatchers(HttpMethod.PATCH, "/api/posts/**", "/api/comments/**", "/api/notifications/**").hasAnyRole("USER", "ADMIN") // (PATCH도 명시)
106+
.requestMatchers(HttpMethod.PATCH, "/api/posts/**", "/api/comments/**", "/api/notifications/**").hasAnyRole("USER", "ADMIN")
107+
.requestMatchers(HttpMethod.GET, "/api/notifications/**").hasAnyRole("USER", "ADMIN")
108+
111109

112-
// ★ (수정) GET을 제외한 나머지 /api/notifications/** 경로는 여기서 처리됩니다.
113-
.requestMatchers("/api/notifications/**").hasAnyRole("USER", "ADMIN")
114110
.requestMatchers("/api/report/**").hasAnyRole("USER", "ADMIN")
115111
.requestMatchers("/api/files/**").hasAnyRole("USER", "ADMIN")
116112
.requestMatchers("/api/collab").hasAnyRole("USER", "ADMIN")

0 commit comments

Comments
 (0)