From 858f515995fd1dca7cf825069ce38c32703298d0 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期五, 07 十一月 2025 14:14:50 +0800
Subject: [PATCH] 报名人员导出

---
 backend/src/main/java/com/rongyichuang/config/SecurityConfig.java |   34 ++++++++++++++++++++++++++--------
 1 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/backend/src/main/java/com/rongyichuang/config/SecurityConfig.java b/backend/src/main/java/com/rongyichuang/config/SecurityConfig.java
index 2e1b542..269f959 100644
--- a/backend/src/main/java/com/rongyichuang/config/SecurityConfig.java
+++ b/backend/src/main/java/com/rongyichuang/config/SecurityConfig.java
@@ -1,5 +1,7 @@
 package com.rongyichuang.config;
 
+import com.rongyichuang.auth.filter.JwtAuthenticationFilter;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.security.authentication.AuthenticationManager;
@@ -11,6 +13,8 @@
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 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;
@@ -24,6 +28,9 @@
 @EnableWebSecurity
 @EnableMethodSecurity
 public class SecurityConfig {
+
+    @Autowired
+    private JwtAuthenticationFilter jwtAuthenticationFilter;
 
     @Bean
     public PasswordEncoder passwordEncoder() {
@@ -42,14 +49,25 @@
             .csrf(csrf -> csrf.disable())
             .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
             .authorizeHttpRequests(auth -> auth
-                .requestMatchers("/api/auth/**").permitAll()
-                .requestMatchers("/api/graphql/**").permitAll()
-                .requestMatchers("/graphql/**").permitAll()
-                .requestMatchers("/graphql").permitAll()
-                .requestMatchers("/api/graphiql").permitAll()
-                .requestMatchers("/api/test/**").permitAll()
-                .anyRequest().permitAll()
-            );
+                .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);
 
         return http.build();
     }

--
Gitblit v1.8.0