|
1 | 1 | package ddingdong.ddingdongBE.common.config;
|
2 | 2 |
|
3 | 3 | import static org.springframework.http.HttpMethod.GET;
|
| 4 | +import static org.springframework.http.HttpMethod.POST; |
4 | 5 |
|
5 | 6 | import ddingdong.ddingdongBE.auth.service.JwtAuthService;
|
6 | 7 | import ddingdong.ddingdongBE.common.filter.JwtAuthenticationFilter;
|
@@ -33,57 +34,58 @@ public class SecurityConfig {
|
33 | 34 | public SecurityFilterChain filterChain(HttpSecurity http, JwtAuthService authService, JwtConfig config)
|
34 | 35 | throws Exception {
|
35 | 36 | http
|
36 |
| - .authorizeHttpRequests(auth -> auth |
37 |
| - .requestMatchers(API_PREFIX + "/auth/**", |
38 |
| - API_PREFIX + "/events/**") |
39 |
| - .permitAll() |
40 |
| - .requestMatchers(API_PREFIX + "/admin/**").hasRole("ADMIN") |
41 |
| - .requestMatchers(API_PREFIX + "/central/**").hasRole("CLUB") |
42 |
| - .requestMatchers(actuatorPath).hasRole("ADMIN") |
43 |
| - .requestMatchers(GET, |
44 |
| - API_PREFIX + "/clubs/**", |
45 |
| - API_PREFIX + "/notices/**", |
46 |
| - API_PREFIX + "/banners/**", |
47 |
| - API_PREFIX + "/documents/**", |
48 |
| - API_PREFIX + "/questions/**", |
49 |
| - API_PREFIX + "/feeds/**", |
50 |
| - API_PREFIX + "/internal/**") |
51 |
| - .permitAll() |
52 |
| - .requestMatchers("/v3/api-docs/**", "/swagger-ui/**", "/swagger-resources/**") |
53 |
| - .permitAll() |
54 |
| - .anyRequest() |
55 |
| - .authenticated() |
56 |
| - ) |
57 |
| - .cors(cors -> cors |
58 |
| - .configurationSource(corsConfigurationSource()) |
59 |
| - ) |
60 |
| - /* |
61 |
| - csrf, headers, http-basic, rememberMe, formLogin 비활성화 |
62 |
| - */ |
63 |
| - .csrf(AbstractHttpConfigurer::disable) |
64 |
| - .headers(AbstractHttpConfigurer::disable) |
65 |
| - .httpBasic(AbstractHttpConfigurer::disable) |
66 |
| - .rememberMe(AbstractHttpConfigurer::disable) |
67 |
| - .formLogin(AbstractHttpConfigurer::disable) |
68 |
| - .logout(AbstractHttpConfigurer::disable) |
69 |
| - /* |
70 |
| - Session 설정 |
71 |
| - */ |
72 |
| - .sessionManagement(session -> session |
73 |
| - .sessionCreationPolicy(SessionCreationPolicy.STATELESS) |
74 |
| - ) |
75 |
| - /* |
76 |
| - Jwt 필터 |
77 |
| - */ |
78 |
| - .addFilterBefore(authenticationFilter(authService, config), |
79 |
| - UsernamePasswordAuthenticationFilter.class) |
80 |
| - /* |
81 |
| - exceptionHandling |
82 |
| - */ |
83 |
| - .exceptionHandling(exceptions -> exceptions |
84 |
| - .authenticationEntryPoint(restAuthenticationEntryPoint()) |
85 |
| - .accessDeniedHandler(accessDeniedHandler()) |
86 |
| - ); |
| 37 | + .authorizeHttpRequests(auth -> auth |
| 38 | + .requestMatchers(API_PREFIX + "/auth/**", |
| 39 | + API_PREFIX + "/events/**") |
| 40 | + .permitAll() |
| 41 | + .requestMatchers(API_PREFIX + "/admin/**").hasRole("ADMIN") |
| 42 | + .requestMatchers(API_PREFIX + "/central/**").hasRole("CLUB") |
| 43 | + .requestMatchers(actuatorPath).hasRole("ADMIN") |
| 44 | + .requestMatchers(GET, |
| 45 | + API_PREFIX + "/clubs/**", |
| 46 | + API_PREFIX + "/notices/**", |
| 47 | + API_PREFIX + "/banners/**", |
| 48 | + API_PREFIX + "/documents/**", |
| 49 | + API_PREFIX + "/questions/**", |
| 50 | + API_PREFIX + "/feeds/**") |
| 51 | + .permitAll() |
| 52 | + .requestMatchers(POST, API_PREFIX + "/internal/**") |
| 53 | + .permitAll() |
| 54 | + .requestMatchers("/v3/api-docs/**", "/swagger-ui/**", "/swagger-resources/**") |
| 55 | + .permitAll() |
| 56 | + .anyRequest() |
| 57 | + .authenticated() |
| 58 | + ) |
| 59 | + .cors(cors -> cors |
| 60 | + .configurationSource(corsConfigurationSource()) |
| 61 | + ) |
| 62 | + /* |
| 63 | + csrf, headers, http-basic, rememberMe, formLogin 비활성화 |
| 64 | + */ |
| 65 | + .csrf(AbstractHttpConfigurer::disable) |
| 66 | + .headers(AbstractHttpConfigurer::disable) |
| 67 | + .httpBasic(AbstractHttpConfigurer::disable) |
| 68 | + .rememberMe(AbstractHttpConfigurer::disable) |
| 69 | + .formLogin(AbstractHttpConfigurer::disable) |
| 70 | + .logout(AbstractHttpConfigurer::disable) |
| 71 | + /* |
| 72 | + Session 설정 |
| 73 | + */ |
| 74 | + .sessionManagement(session -> session |
| 75 | + .sessionCreationPolicy(SessionCreationPolicy.STATELESS) |
| 76 | + ) |
| 77 | + /* |
| 78 | + Jwt 필터 |
| 79 | + */ |
| 80 | + .addFilterBefore(authenticationFilter(authService, config), |
| 81 | + UsernamePasswordAuthenticationFilter.class) |
| 82 | + /* |
| 83 | + exceptionHandling |
| 84 | + */ |
| 85 | + .exceptionHandling(exceptions -> exceptions |
| 86 | + .authenticationEntryPoint(restAuthenticationEntryPoint()) |
| 87 | + .accessDeniedHandler(accessDeniedHandler()) |
| 88 | + ); |
87 | 89 |
|
88 | 90 | return http.build();
|
89 | 91 | }
|
|
0 commit comments