Просмотр исходного кода

fix(config): 修正三方接口路径为charge-business前缀

- 更新 application-dev.yml 中相关接口路径,将/dev/v1/替换为/charge-business/v1/
- 修改 ThirdPartyJwtAuthFilter 中三方路径列表,保持与配置文件一致
- 确保三方接口路径统一,避免路由冲突和安全策略失效
- 优化了路径匹配的准确性,提升系统稳定性
SheepHy 2 дней назад
Родитель
Сommit
2de503b018

+ 5 - 5
src/main/java/com/zsElectric/boot/common/util/electric/queryToken/ThirdPartyJwtAuthFilter.java

@@ -31,11 +31,11 @@ public class ThirdPartyJwtAuthFilter extends OncePerRequestFilter {
 
 
     // 定义你的第三方接口路径模式,例如 /api/third-party/**
     // 定义你的第三方接口路径模式,例如 /api/third-party/**
     private final List<String> thirdPartyApiPaths = Arrays.asList(
     private final List<String> thirdPartyApiPaths = Arrays.asList(
-            "/dev/v1/linkData/notification_start_charge_result",
-            "/dev/v1/linkData/notification_equip_charge_status",
-            "/dev/v1/linkData/notification_stop_charge_result",
-            "/dev/v1/linkData/notification_charge_order_info",
-            "/dev/v1/linkData/notification_stationStatus"
+            "/charge-business/v1/linkData/notification_start_charge_result",
+            "/charge-business/v1/linkData/notification_equip_charge_status",
+            "/charge-business/v1/linkData/notification_stop_charge_result",
+            "/charge-business/v1/linkData/notification_charge_order_info",
+            "/charge-business/v1/linkData/notification_stationStatus"
     );
     );
     private final AntPathMatcher pathMatcher = new AntPathMatcher();
     private final AntPathMatcher pathMatcher = new AntPathMatcher();
     
     

+ 6 - 6
src/main/resources/application-dev.yml

@@ -114,15 +114,15 @@ security:
     - /v3/api-docs/**
     - /v3/api-docs/**
     - /webjars/**
     - /webjars/**
     - /favicon.ico
     - /favicon.ico
-    - /dev/v1/linkData/**
+    - /charge-business/v1/linkData/**
     - /applet/v1/homePage/** # 用户端分页查询站点信息
     - /applet/v1/homePage/** # 用户端分页查询站点信息
   # 只走第三方过滤器、不走其他安全链
   # 只走第三方过滤器、不走其他安全链
   third-party-urls:
   third-party-urls:
-    - /dev/v1/linkData/notification_start_charge_result
-    - /dev/v1/linkData/notification_equip_charge_status
-    - /dev/v1/linkData/notification_stop_charge_result
-    - /dev/v1/linkData/notification_charge_order_info
-    - /dev/v1/linkData/notification_stationStatus
+    - /charge-business/v1/linkData/notification_start_charge_result
+    - /charge-business/v1/linkData/notification_equip_charge_status
+    - /charge-business/v1/linkData/notification_stop_charge_result
+    - /charge-business/v1/linkData/notification_charge_order_info
+    - /charge-business/v1/linkData/notification_stationStatus
 
 
   # XSS 和 SQL 注入防护过滤器配置
   # XSS 和 SQL 注入防护过滤器配置
   filter:
   filter:

+ 82 - 40
src/main/resources/application-prod.yml

@@ -75,26 +75,38 @@ mybatis-plus:
     # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
     # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
 
+# 异步线程池配置
+async:
+  thread-pool:
+    core-pool-size: 10
+    max-pool-size: 50
+    queue-capacity: 1000
+    keep-alive-seconds: 60
+    thread-name-prefix: "business-async-"
+    allow-core-thread-timeout: false
+    await-termination-seconds: 30
+
 # 安全配置
 # 安全配置
 security:
 security:
   session:
   session:
-    type: jwt # 会话方式 [jwt|redis-token]
-    access-token-time-to-live: 7200   # 访问令牌 有效期(单位:秒),默认 2 小时,-1 表示永不过期
-    refresh-token-time-to-live: 604800   # 刷新令牌有效期(单位:秒),默认 7 天,-1 表示永不过期
+    type: jwt # 会话方式 jwt/redis-token
+    access-token-time-to-live: 7200 # 访问令牌 有效期(单位:秒),默认 2 小时,-1 表示永不过期
+    refresh-token-time-to-live: 604800 # 刷新令牌有效期(单位:秒),默认 7 天,-1 表示永不过期
     jwt:
     jwt:
       secret-key: SecretKey012345678901234567890123456789012345678901234567890123456789 # JWT密钥(HS256算法至少32字符)
       secret-key: SecretKey012345678901234567890123456789012345678901234567890123456789 # JWT密钥(HS256算法至少32字符)
     redis-token:
     redis-token:
       allow-multi-login: true # 是否允许多设备登录
       allow-multi-login: true # 是否允许多设备登录
-  # 安全白名单路径,仅跳过 AuthorizationFilter 过滤器,还是会走 Spring Security 的其他过滤器(CSRF、CORS等)
+  # 安全白名单路径,仅跳过 AuthorizationFilter 过滤器还是会走 Spring Security 的其他过滤器(CSRF、CORS等)
   ignore-urls:
   ignore-urls:
-    - /api/v1/auth/login/**       # 登录接口(账号密码登录、手机验证码登录和微信登录)
-    - /api/v1/auth/captcha        # 验证码获取接口
-    - /api/v1/auth/refresh-token  # 刷新令牌接口
-    - /api/v1/auth/logout         # 开放退出登录
-    - /api/v1/auth/wx/**          # 微信相关所有接口(包括code登录、手机号登录、手机号Code登录)
-    - /ws/**                      # WebSocket接口
-#    - /dev/v1/linkData/** #互联互通
-  # 非安全端点路径,完全绕过 Spring Security 的过滤器
+    - /api/v1/auth/login/** # 登录接口(账号密码登录、手机验证码登录和微信登录)
+    - /api/v1/auth/captcha # 验证码获取接口
+    - /api/v1/auth/refresh-token # 刷新令牌接口
+    - /api/v1/auth/logout # 开放退出登录
+    - /api/v1/auth/wx/** # 微信相关所有接口
+    - /ws/** # WebSocket接口
+    - /applet/v1/homePage/** # 用户端分页查询站点信息
+
+  # 非安全端点路径,完全绕过 Spring Security 的安全控制
   unsecured-urls:
   unsecured-urls:
     - ${springdoc.swagger-ui.path}
     - ${springdoc.swagger-ui.path}
     - /doc.html
     - /doc.html
@@ -102,41 +114,70 @@ security:
     - /v3/api-docs/**
     - /v3/api-docs/**
     - /webjars/**
     - /webjars/**
     - /favicon.ico
     - /favicon.ico
-    - /dev/v1/linkData/**
+    - /charge-business/v1/linkData/**
+    - /applet/v1/homePage/** # 用户端分页查询站点信息
   # 只走第三方过滤器、不走其他安全链
   # 只走第三方过滤器、不走其他安全链
   third-party-urls:
   third-party-urls:
-    - /dev/v1/linkData/notification_start_charge_result
-    - /dev/v1/linkData/notification_equip_charge_status
-    - /dev/v1/linkData/notification_stop_charge_result
-    - /dev/v1/linkData/notification_charge_order_info
-    - /dev/v1/linkData/notification_stationStatus
+    - /charge-business/v1/linkData/notification_start_charge_result
+    - /charge-business/v1/linkData/notification_equip_charge_status
+    - /charge-business/v1/linkData/notification_stop_charge_result
+    - /charge-business/v1/linkData/notification_charge_order_info
+    - /charge-business/v1/linkData/notification_stationStatus
+
+  # XSS 和 SQL 注入防护过滤器配置
+  filter:
+    # 是否启用 XSS 防护
+    xss-enabled: true
+    # 是否启用 SQL 注入防护
+    sql-injection-enabled: true
+    # SQL 注入检测严格模式
+    # true: 严格模式,可能误判一些正常输入
+    # false: 宽松模式,减少误判但可能漏掉一些攻击
+    sql-strict-mode: true
+    # 排除的 URL 路径(不进行安全检查,注意:默认已经排除了 /doc.html、/swagger-ui 等接口文档相关路径)
+    exclude-urls:
+      - /api/v1/auth/captcha  # 验证码接口
+    # 额外需要检查的请求头(默认已检查 User-Agent、Referer、X-Forwarded-For)
+    check-headers:
+      - Referer
+      - X-Forwarded-For
+
+okhttp:
+  connect-timeout: 30s
+  read-timeout: 120s
+  write-timeout: 60s
+  retry-on-connection-failure: true
+  max-retry-count: 2
+  connection-pool:
+    max-idle-connections: 200
+    keep-alive-duration: 300s
 
 
 # 文件存储配置
 # 文件存储配置
 oss:
 oss:
-  # OSS 类型 (目前支持aliyun、minio)
+  # OSS 类型 (目前支持aliyun、minio、local)
   type: aliyun
   type: aliyun
   # MinIO 对象存储服务
   # MinIO 对象存储服务
   minio:
   minio:
-    # 服务Endpoint
+    # MinIO 服务地址
     endpoint: http://localhost:9000
     endpoint: http://localhost:9000
     # 访问凭据
     # 访问凭据
     access-key: minioadmin
     access-key: minioadmin
     # 凭据密钥
     # 凭据密钥
     secret-key: minioadmin
     secret-key: minioadmin
     # 存储桶名称
     # 存储桶名称
-    bucket-name: public
-    # (可选)自定义域名,如果配置了域名,生成的文件URL是域名格式,未配置则URL则是IP格式 (eg: https://oss.youlai.tech)
+    bucket-name: zsElectric
+    # (可选) 自定义域名:配置后,文件 URL 会使用该域名格式
     custom-domain:
     custom-domain:
   # 阿里云OSS对象存储服务
   # 阿里云OSS对象存储服务
   aliyun:
   aliyun:
     # 服务Endpoint
     # 服务Endpoint
-    endpoint: oss-cn-chengdu.aliyuncs.com
-    # 访问凭据
+    endpoint: oss-cn-beijing.aliyuncs.com
+    # 访问凭据`
     access-key-id: LTAI5tJscqbev7wSugGCrEtt
     access-key-id: LTAI5tJscqbev7wSugGCrEtt
     # 凭据密钥
     # 凭据密钥
     access-key-secret: xJkoJR1ILpXNSF2ERnxNq71UZTQNcB
     access-key-secret: xJkoJR1ILpXNSF2ERnxNq71UZTQNcB
     # 存储桶名称
     # 存储桶名称
-    bucket-name: zs-electric
+    bucket-name: national-motion
   # 本地存储
   # 本地存储
   local:
   local:
     # 文件存储路径 请注意下,mac用户请使用 /Users/your-username/your-path/,否则会有权限问题,windows用户请使用 D:/your-path/
     # 文件存储路径 请注意下,mac用户请使用 /Users/your-username/your-path/,否则会有权限问题,windows用户请使用 D:/your-path/
@@ -145,11 +186,11 @@ oss:
 sms:
 sms:
   # 阿里云短信
   # 阿里云短信
   aliyun:
   aliyun:
-    accessKeyId: LTAI5tSMgfxxxxxxdiBJLyR
-    accessKeySecret: SoOWRqpjtS7xxxxxxZ2PZiMTJOVC
+    accessKeyId: xxx
+    accessKeySecret: xxx
     domain: dysmsapi.aliyuncs.com
     domain: dysmsapi.aliyuncs.com
     regionId: cn-shanghai
     regionId: cn-shanghai
-    signName: 有来技术
+    signName: 中数未来
     templates:
     templates:
       #  注册短信验证码模板
       #  注册短信验证码模板
       register: SMS_22xxx771
       register: SMS_22xxx771
@@ -162,12 +203,12 @@ sms:
 springdoc:
 springdoc:
   swagger-ui:
   swagger-ui:
     path: /swagger-ui.html
     path: /swagger-ui.html
-    operationsSorter: alpha
+    operations-sorter: alpha
     tags-sorter: alpha
     tags-sorter: alpha
   api-docs:
   api-docs:
     path: /v3/api-docs
     path: /v3/api-docs
   group-configs:
   group-configs:
-    - group: '系统管理'
+    - group: "系统管理"
       paths-to-match: "/**"
       paths-to-match: "/**"
       packages-to-scan:
       packages-to-scan:
         - com.zsElectric.boot.auth.controller
         - com.zsElectric.boot.auth.controller
@@ -182,9 +223,9 @@ springdoc:
 # knife4j 接口文档配置
 # knife4j 接口文档配置
 knife4j:
 knife4j:
   # 是否开启 Knife4j 增强功能
   # 是否开启 Knife4j 增强功能
-  enable: true  # 设置为 true 表示开启增强功能
+  enable: true # 设置为 true 表示开启增强功能
   # 生产环境配置
   # 生产环境配置
-  production: false  # 设置为 true 表示在生产环境中不显示文档,为 false 表示显示文档(通常在开发环境中使用)
+  production: false # 设置为 true 表示在生产环境中不显示文档,为 false 表示显示文档(通常在开发环境中使用)
   setting:
   setting:
     language: zh_cn
     language: zh_cn
 
 
@@ -194,16 +235,17 @@ xxl:
     # 定时任务开关
     # 定时任务开关
     enabled: false
     enabled: false
     admin:
     admin:
-      # 多个地址使用,分割
-      addresses: http://127.0.0.1:8686/xxl-job-admin
+      # 调度中心地址,多个逗号分隔
+      addresses: http://127.0.0.1:8080/xxl-job-admin
     accessToken: default_token
     accessToken: default_token
+    # 执行器配置
     executor:
     executor:
-      appname: xxl-job-executor-${spring.application.name}
-      address:
-      ip:
-      port: 9999
-      logpath: /data/applogs/xxl-job/jobhandler
-      logretentiondays: 30
+      appname: xxl-job-executor-${spring.application.name} # 执行器AppName
+      address: # 执行器注册地址,默认为空,多网卡时可手动设置
+      ip: # 执行器IP,默认为空,多网卡时可手动设置
+      port: 9999 # 执行器通讯端口
+      logpath: /data/applogs/xxl-job/jobhandler # 任务运行日志文件存储磁盘路径
+      logretentiondays: 30 # 日志保存天数,值大于3时生效
 
 
 # 验证码配置
 # 验证码配置
 captcha:
 captcha: