|
9 | 9 | import org.muses.backendbulidtest251228.global.security.handler.OAuth2LoginSuccessHandler; |
10 | 10 | import org.springframework.context.annotation.Bean; |
11 | 11 | import org.springframework.context.annotation.Configuration; |
| 12 | +import org.springframework.http.HttpMethod; |
12 | 13 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
13 | 14 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
14 | 15 | import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; |
@@ -42,21 +43,31 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { |
42 | 43 | // JWT 사용 -> 세션 사용 X |
43 | 44 | .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) |
44 | 45 | .authorizeHttpRequests(auth -> auth |
45 | | - // Swagger 허용 |
46 | | - .requestMatchers("/swagger-ui/**", "/swagger-ui.html", "/api-docs/**", "/v3/api-docs/**","/api/landing").permitAll() |
47 | | - // QR 화면 허용 |
| 46 | + // ==== 인프라/정적 리소스 ==== |
| 47 | + .requestMatchers( |
| 48 | + "/swagger-ui/**", "/swagger-ui.html", |
| 49 | + "/api-docs/**", "/v3/api-docs/**", |
| 50 | + "/health", "/error", |
| 51 | + "/files/**" |
| 52 | + ).permitAll() |
| 53 | + // ==== 인증 API ==== |
| 54 | + .requestMatchers( |
| 55 | + "/api/auth/signup", |
| 56 | + "/api/auth/login", |
| 57 | + "/api/auth/signup/check-email", |
| 58 | + "/login/**", |
| 59 | + "/oauth2/**", |
| 60 | + "/auth/callback" |
| 61 | + ).permitAll() |
| 62 | + // ==== 공개 API ==== |
| 63 | + .requestMatchers(HttpMethod.POST, "/api/landing").permitAll() |
| 64 | + .requestMatchers(HttpMethod.GET, "/api/projects/**").permitAll() |
| 65 | + .requestMatchers(HttpMethod.GET, "/api/events/**").permitAll() |
| 66 | + .requestMatchers(HttpMethod.GET, "/api/alarms/**").permitAll() |
| 67 | + // ==== QR 체크인 결과 ==== |
48 | 68 | .requestMatchers("/api/checkin/result", "/checkin/result").permitAll() |
49 | | - .requestMatchers("/api/auth/profile/**", "/api/users/me/**").authenticated() |
50 | | - .requestMatchers("/login/**", "/auth/callback", "/api/auth/**", "/oauth2/**", "/api/projects/**", "/api/alarms/**", "/api/events/**", "/health", "/error").permitAll() |
51 | | - .requestMatchers(org.springframework.http.HttpMethod.GET, "/api/creators/applications/me").authenticated() |
52 | | - .requestMatchers(org.springframework.http.HttpMethod.POST, "/api/creators/applications").authenticated() |
53 | | - .requestMatchers(org.springframework.http.HttpMethod.POST, "/api/creators/applications/me/docs").authenticated() |
54 | | - .requestMatchers(org.springframework.http.HttpMethod.GET, "/api/creators/applications/me/docs").authenticated() |
55 | | - .requestMatchers(org.springframework.http.HttpMethod.POST, "/api/creators/applications/me/submit").authenticated() |
56 | | - .requestMatchers("/api/creators/**").hasRole("CREATOR") |
| 69 | + // ==== 관리자 전용 ==== |
57 | 70 | .requestMatchers("/api/admin/**").hasRole("ADMIN") |
58 | | - // TODO 정적 파일 (업로드된 이미지) 허용 |
59 | | - .requestMatchers("/files/**").permitAll() |
60 | 71 | .anyRequest().authenticated() |
61 | 72 | ) |
62 | 73 | // JWT 필터 등록 |
|
0 commit comments