|
17 | 17 | import org.springframework.security.web.authentication.HttpStatusEntryPoint; |
18 | 18 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; |
19 | 19 | import org.springframework.security.web.util.matcher.AntPathRequestMatcher; |
| 20 | +import org.springframework.security.web.util.matcher.RegexRequestMatcher; |
20 | 21 | import org.springframework.web.cors.CorsConfigurationSource; |
21 | 22 | import org.springframework.beans.factory.annotation.Value; |
22 | 23 |
|
@@ -56,9 +57,10 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti |
56 | 57 | http.authorizeHttpRequests(auth -> auth |
57 | 58 | // .anyRequest().permitAll()); |
58 | 59 | .requestMatchers("/img/**", "/css/**", "/js/**", "/favicon.ico", "/error").permitAll() |
59 | | - .requestMatchers("/swagger-ui/**","/v3/api-docs/**").permitAll() // 토큰 재발급 요청은 누구나 가능 |
60 | | - .requestMatchers("/api/token").permitAll() |
61 | | -// .requestMatchers("/api/users/**").hasAnyRole("USER", "ADMIN") // 유저 관련 API는 USER 또는 ADMIN 권한 필요 |
| 60 | + .requestMatchers("/swagger-ui/**","/v3/api-docs/**").permitAll() //누구나 가능 |
| 61 | + .requestMatchers("/api/token", "/api/products/latest","/api/products/search/**").permitAll() //누구나 가능 |
| 62 | + .requestMatchers(new RegexRequestMatcher("^/api/products/\\d+$", "GET")).permitAll() |
| 63 | + .requestMatchers("/api/users/**").hasAnyRole("USER", "ADMIN") // 유저 관련 API는 USER 또는 ADMIN 권한 필요 |
62 | 64 | .requestMatchers("/api/admin/**").hasRole("ADMIN") // 어드민 관련 API는 ADMIN 권한만 가능 |
63 | 65 | .anyRequest().authenticated()); // 나머지 요청은 인증 필요 |
64 | 66 |
|
|
0 commit comments