| | |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | import org.springframework.security.web.SecurityFilterChain; |
| | | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; |
| | | import org.springframework.security.web.util.matcher.AntPathRequestMatcher; |
| | | import org.springframework.web.cors.CorsConfiguration; |
| | | import org.springframework.web.cors.CorsConfigurationSource; |
| | | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
| | |
| | | .csrf(csrf -> csrf.disable()) |
| | | .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) |
| | | .authorizeHttpRequests(auth -> auth |
| | | .requestMatchers("/auth/**", "/actuator/**", "/test/**", "/cleanup/**").permitAll() |
| | | .requestMatchers("/upload/**").permitAll() |
| | | .requestMatchers("/graphiql/**", "/graphql/**", "/api/graphql/**", "/api/graphiql/**").permitAll() // 允许GraphQL和GraphiQL访问 |
| | | .requestMatchers("/**/graphql", "/**/graphiql").permitAll() // 更宽泛的GraphQL路径匹配 |
| | | .requestMatchers( |
| | | new AntPathRequestMatcher("/auth/**"), |
| | | new AntPathRequestMatcher("/api/auth/**"), |
| | | new AntPathRequestMatcher("/actuator/**"), |
| | | new AntPathRequestMatcher("/test/**"), |
| | | new AntPathRequestMatcher("/cleanup/**"), |
| | | new AntPathRequestMatcher("/api/health/**"), |
| | | new AntPathRequestMatcher("/upload/**"), |
| | | new AntPathRequestMatcher("/api/upload/**"), |
| | | new AntPathRequestMatcher("/graphiql/**"), |
| | | new AntPathRequestMatcher("/graphql/**"), |
| | | new AntPathRequestMatcher("/api/graphql/**"), |
| | | new AntPathRequestMatcher("/api/graphiql/**"), |
| | | new AntPathRequestMatcher("/player/export/applications"), |
| | | new AntPathRequestMatcher("/api/player/export/applications") |
| | | ).permitAll() |
| | | .anyRequest().authenticated() |
| | | ) |
| | | .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); |