feat: 更新安全配置和日志输出
主要修改: 1. 在SecurityConfig中允许所有CORS预检请求(OPTIONS)公开访问。 2. 更新日志输出,增加对OPTIONS请求的权限配置说明。 技术细节: - 通过允许OPTIONS请求,增强了跨域资源共享(CORS)的支持,提升了前端与后端的交互能力。
This commit is contained in:
@@ -39,6 +39,7 @@ public class SecurityConfig {
|
||||
.authenticationManager(authenticationManager())
|
||||
.authorizeExchange(ex -> ex
|
||||
.pathMatchers("/actuator/**").permitAll()
|
||||
.pathMatchers(HttpMethod.OPTIONS, "/**").permitAll() // 允许所有CORS预检请求
|
||||
.pathMatchers(HttpMethod.POST, "/api/auth/login").permitAll()
|
||||
.pathMatchers(HttpMethod.GET, "/api/auth/me").permitAll()
|
||||
.pathMatchers(HttpMethod.GET, "/api/link/status").permitAll() // 用户端获取链接状态接口,公开访问
|
||||
@@ -62,6 +63,7 @@ public class SecurityConfig {
|
||||
log.info(" - JWT过滤器: 已集成到Security链中 (AUTHENTICATION位置)");
|
||||
log.info(" - 路径权限配置:");
|
||||
log.info(" * /actuator/** -> 允许所有");
|
||||
log.info(" * OPTIONS /** -> 允许所有 (CORS预检请求)");
|
||||
log.info(" * POST /api/auth/login -> 允许所有");
|
||||
log.info(" * GET /api/auth/me -> 允许所有");
|
||||
log.info(" * GET /api/link/status -> 允许所有 (用户端公开接口)");
|
||||
|
||||
@@ -3,7 +3,7 @@ spring:
|
||||
name: gameplatform-server
|
||||
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/login_task_db?useSSL=false&serverTimezone=UTC&characterEncoding=utf8&allowPublicKeyRetrieval=true
|
||||
url: jdbc:mysql://192.140.164.137:3306/login_task_db?useSSL=false&serverTimezone=UTC&characterEncoding=utf8&allowPublicKeyRetrieval=true
|
||||
username: login_task_db
|
||||
password: 3MaXfeWJ4d6cGMrL
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
@@ -70,7 +70,7 @@ script:
|
||||
|
||||
# 服务器配置
|
||||
app:
|
||||
base-url: "http://localhost:18080" # 生产环境需要配置为实际域名
|
||||
base-url: "http://192.140.164.137:18080" # 生产环境需要配置为实际域名
|
||||
image-save-path: "./images" # 图片保存路径
|
||||
|
||||
link:
|
||||
|
||||
Reference in New Issue
Block a user