Skip to content

Commit

Permalink
feat: 모니터링 관련 경로 white list에 추가 #19
Browse files Browse the repository at this point in the history
  • Loading branch information
leedy3838 committed Sep 13, 2024
1 parent ccb3860 commit 16e467d
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions src/main/java/com/shwimping/be/global/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
Expand All @@ -28,18 +27,18 @@ public class SecurityConfig {
private final JwtAuthenticationFilter jwtAuthenticationFilter;
private final MapAuthenticationFilter mapAuthenticationFilter;

@Bean
public WebSecurityCustomizer webSecurityCustomizer() { // security를 적용하지 않을 리소스
return web -> web.ignoring()
.requestMatchers(
"/error",
"/swagger-ui/**",
"/v3/api-docs/**",
"/swagger-resources/*",
"/webjars/**",
"/auth/**",
"/global/health-check");
}
private final String[] WHITE_LIST = {
"/error",
"/swagger-ui/**",
"/v3/api-docs/**",
"/swagger-resources/*",
"/webjars/**",
"/auth/**",
"/global/health-check",
"/places/**",
"/reviews/*",
"/actuator/**"
};

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
Expand All @@ -48,10 +47,10 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.httpBasic(AbstractHttpConfigurer::disable) // HTTP 기본 인증을 비활성화
.cors(Customizer.withDefaults()) // CORS 활성화 - corsConfigurationSource 이름의 빈 사용
.csrf(AbstractHttpConfigurer::disable) // CSRF 보호 기능 비활성화
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) // JWT 사용해서 세션 사용 X
.sessionManagement(
session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) // JWT 사용해서 세션 사용 X
.authorizeHttpRequests(auth -> auth // 요청에 대한 인증 설정
.requestMatchers("/places/**").permitAll()
.requestMatchers("/reviews/*").permitAll()
.requestMatchers(WHITE_LIST).permitAll()
.anyRequest().authenticated()) //이외의 요청은 전부 인증 필요
.exceptionHandling(exceptionHandling -> {
exceptionHandling
Expand Down

0 comments on commit 16e467d

Please sign in to comment.