Skip to content

Commit 1a0e8d2

Browse files
authored
Merge pull request #63 from Decodeat/Refactor/#62
Refactor: 관리자 API 권한 설정 추가
2 parents e914de2 + dbcf6bf commit 1a0e8d2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/main/java/com/DecodEat/domain/report/controller/AdminReportController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
import io.swagger.v3.oas.annotations.responses.ApiResponses;
1111
import io.swagger.v3.oas.annotations.tags.Tag;
1212
import lombok.RequiredArgsConstructor;
13+
import org.springframework.security.access.prepost.PreAuthorize;
1314
import org.springframework.web.bind.annotation.*;
1415

1516
@RestController
1617
@RequiredArgsConstructor
1718
@RequestMapping("/api/admin/reports")
1819
@Tag(name = "[관리자] 신고 관리")
20+
@PreAuthorize("hasRole('ADMIN')")
1921
public class AdminReportController {
2022

2123
private final ReportService reportService;

src/main/java/com/DecodEat/global/config/WebOAuthSecurityConfig.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
5454

5555
// 3. 요청별 인가 규칙 설정
5656
http.authorizeHttpRequests(auth -> auth
57-
.anyRequest().permitAll());
58-
// .requestMatchers("/img/**", "/css/**", "/js/**", "/favicon.ico", "/error").permitAll()
59-
// .requestMatchers("/swagger-ui/**","/v3/api-docs/**").permitAll() // 토큰 재발급 요청은 누구나 가능
60-
// .requestMatchers("/api/token").permitAll()
57+
// .anyRequest().permitAll());
58+
.requestMatchers("/img/**", "/css/**", "/js/**", "/favicon.ico", "/error").permitAll()
59+
.requestMatchers("/swagger-ui/**","/v3/api-docs/**").permitAll() // 토큰 재발급 요청은 누구나 가능
60+
.requestMatchers("/api/token").permitAll()
6161
// .requestMatchers("/api/users/**").hasAnyRole("USER", "ADMIN") // 유저 관련 API는 USER 또는 ADMIN 권한 필요
62-
// .requestMatchers("/api/admin/**").hasRole("ADMIN") // 어드민 관련 API는 ADMIN 권한만 가능
63-
// .anyRequest().authenticated()); // 나머지 요청은 인증 필요
62+
.requestMatchers("/api/admin/**").hasRole("ADMIN") // 어드민 관련 API는 ADMIN 권한만 가능
63+
.anyRequest().authenticated()); // 나머지 요청은 인증 필요
6464

6565
// 4. OAuth2 로그인 설정
6666
http.oauth2Login(oauth2 -> oauth2

0 commit comments

Comments
 (0)