Skip to content

Commit 6854af6

Browse files
authored
Merge pull request #69 from Decodeat/Refactor/#64
Fix: 권한 설정
2 parents fb78e88 + 314b2aa commit 6854af6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
1818
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
1919
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
20+
import org.springframework.security.web.util.matcher.RegexRequestMatcher;
2021
import org.springframework.web.cors.CorsConfigurationSource;
2122
import org.springframework.beans.factory.annotation.Value;
2223

@@ -56,9 +57,10 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
5657
http.authorizeHttpRequests(auth -> auth
5758
// .anyRequest().permitAll());
5859
.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 권한 필요
6264
.requestMatchers("/api/admin/**").hasRole("ADMIN") // 어드민 관련 API는 ADMIN 권한만 가능
6365
.anyRequest().authenticated()); // 나머지 요청은 인증 필요
6466

0 commit comments

Comments
 (0)