feat:【站内信】

This commit is contained in:
zpaeng
2025-08-21 23:42:53 +08:00
parent d8b3c68150
commit 84ab87878a
27 changed files with 1970 additions and 14 deletions

View File

@@ -92,7 +92,7 @@ public class SecurityConfig {
cfg.setAllowedHeaders(List.of("*"));
cfg.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/api/**", cfg);
source.registerCorsConfiguration("/**", cfg);
return source;
}
@@ -104,6 +104,7 @@ public class SecurityConfig {
.exceptionHandling(eh -> eh.accessDeniedHandler(customAccessDeniedHandler))
.authorizeHttpRequests(auth -> auth
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.requestMatchers("/ws/**").permitAll()
.requestMatchers(HttpMethod.POST, "/api/auth/**").permitAll()
.requestMatchers(HttpMethod.GET, "/api/posts/**").permitAll()
.requestMatchers(HttpMethod.GET, "/api/comments/**").permitAll()
@@ -172,7 +173,7 @@ public class SecurityConfig {
response.getWriter().write("{\"error\": \"Invalid or expired token\"}");
return;
}
} else if (!uri.startsWith("/api/auth") && !publicGet) {
} else if (!uri.startsWith("/api/auth") && !publicGet && !uri.startsWith("/ws")) {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.setContentType("application/json");
response.getWriter().write("{\"error\": \"Missing token\"}");