|
@@ -36,18 +36,13 @@ public class SecurityConfig {
|
|
|
.csrf(csrf -> csrf.disable())
|
|
.csrf(csrf -> csrf.disable())
|
|
|
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
|
|
.sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
|
|
|
|
|
|
|
|
- if (authProperties.isEnabled()) {
|
|
|
|
|
|
|
+
|
|
|
// 生产模式:所有 /api/** 需要鉴权,公开路径仅限登录和静态资源
|
|
// 生产模式:所有 /api/** 需要鉴权,公开路径仅限登录和静态资源
|
|
|
- http.authorizeHttpRequests(auth -> auth
|
|
|
|
|
- .requestMatchers("/health", "/api/v1/auth/**", "/api/v1/quick-asks").permitAll()
|
|
|
|
|
- .requestMatchers("/static/**", "/").permitAll()
|
|
|
|
|
- .requestMatchers("/api/**").authenticated()
|
|
|
|
|
- .anyRequest().permitAll()
|
|
|
|
|
- );
|
|
|
|
|
- } else {
|
|
|
|
|
- // 开发模式:全部放行
|
|
|
|
|
- http.authorizeHttpRequests(auth -> auth.anyRequest().permitAll());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ http.authorizeHttpRequests(auth -> auth
|
|
|
|
|
+ .requestMatchers("/health", "/api/v1/auth/**", "/api/v1/yaodian/**").permitAll()
|
|
|
|
|
+ .requestMatchers("/static/**", "/").permitAll()
|
|
|
|
|
+ .requestMatchers("/api/**").authenticated()
|
|
|
|
|
+ .anyRequest().permitAll());
|
|
|
|
|
|
|
|
http.addFilterBefore(rateLimitFilter, UsernamePasswordAuthenticationFilter.class);
|
|
http.addFilterBefore(rateLimitFilter, UsernamePasswordAuthenticationFilter.class);
|
|
|
http.addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class);
|
|
http.addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class);
|