feat(密钥): 用户 API 密钥服务端化——V115 按账号绑定存储 + 后台密钥管理页 + 桌面端全站拦截与配置引导
- 新增 usersecret 模块:外观专利/货源查询密钥从本地 localStorage 迁移至 biz_user_api_secret(AES 加密、按 uid 绑定) - 后台「密钥管理」页:脱敏展示、立即检测、清空;每日 04:30 分布式锁定时巡检 - 桌面端:密钥设置面板走服务端、未配齐引导 /setup-secrets、代理余量展示 - 删除专利汇令牌全链路与密钥保留时长选择器
This commit is contained in:
@@ -65,6 +65,14 @@ public class AdminApiGuardFilter extends OncePerRequestFilter {
|
||||
"/api/price-track",
|
||||
};
|
||||
|
||||
/**
|
||||
* 桌面端自助接口前缀:新建端点、无历史匿名调用方,无条件纳入兜底鉴权
|
||||
* (controller 内 requireUser 为主防线,此处双保险;不挂 user-tool-guard-enabled 开关)。
|
||||
*/
|
||||
private static final String[] SELF_SERVICE_PREFIXES = {
|
||||
"/api/user-secrets",
|
||||
};
|
||||
|
||||
private final AdminAuthSupport adminAuthSupport;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@@ -131,11 +139,16 @@ public class AdminApiGuardFilter extends OncePerRequestFilter {
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
|
||||
/** 命中受保护前缀(/api/admin、/debug、用户态工具前缀及其子路径)才进入鉴权,其余请求直接放行。 */
|
||||
/** 命中受保护前缀(/api/admin、/debug、自助接口、用户态工具前缀及其子路径)才进入鉴权,其余请求直接放行。 */
|
||||
private boolean isGuarded(String uri) {
|
||||
if (matchesPrefix(uri, ADMIN_API_PREFIX) || matchesPrefix(uri, DEBUG_PREFIX)) {
|
||||
return true;
|
||||
}
|
||||
for (String prefix : SELF_SERVICE_PREFIXES) {
|
||||
if (matchesPrefix(uri, prefix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!userToolGuardEnabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({OssProperties.class, TransientStorageProperties.class, StorageProperties.class, BrandProgressProperties.class, DeleteBrandProgressProperties.class, BrandCheckProperties.class, ZiniaoProperties.class, ModuleCleanupProperties.class, TaskPressureProperties.class, TaskImageCacheCleanupProperties.class, AppearancePatentProperties.class, SimilarAsinProperties.class, ImageVideoProperties.class, InstanceRoutingProperties.class, CapacityPlanProperties.class})
|
||||
@EnableConfigurationProperties({OssProperties.class, TransientStorageProperties.class, StorageProperties.class, BrandProgressProperties.class, DeleteBrandProgressProperties.class, BrandCheckProperties.class, ZiniaoProperties.class, ModuleCleanupProperties.class, TaskPressureProperties.class, TaskImageCacheCleanupProperties.class, AppearancePatentProperties.class, SimilarAsinProperties.class, ImageVideoProperties.class, InstanceRoutingProperties.class, CapacityPlanProperties.class, UserSecretProperties.class})
|
||||
public class PropertiesConfig {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.nanri.aiimage.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* 用户 API 密钥(外观专利密钥 / 货源查询密钥)服务端化配置。
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "aiimage.user-secret")
|
||||
public class UserSecretProperties {
|
||||
|
||||
/** 每日定时连通性巡检开关(应急可关,无需重新打包)。 */
|
||||
private boolean checkEnabled = true;
|
||||
|
||||
/** 巡检 cron(默认每天 04:30,Asia/Shanghai)。 */
|
||||
private String checkCron = "0 30 4 * * *";
|
||||
|
||||
/** 单轮巡检最多检测条数,超出顺延下一轮。 */
|
||||
private int checkMaxRows = 500;
|
||||
|
||||
/** 单轮巡检时间预算(分钟),超时中断本轮。 */
|
||||
private int checkBudgetMinutes = 20;
|
||||
|
||||
/**
|
||||
* 检测出口代理提取链接(选配):配置后检测请求优先经该代理 IP 发出,
|
||||
* 代理不可用时自动回退直连;留空则全部直连。
|
||||
*/
|
||||
private String checkProxyExtractUrl = "";
|
||||
|
||||
/** jikip 余量查询接口(客户端设置弹窗展示套餐 IP 余量 / 账户余额)。 */
|
||||
private String jikipBalanceUrl = "https://api.jikip.com/find-balance";
|
||||
|
||||
/** jikip 套餐 id(余量查询参数)。 */
|
||||
private String jikipPlanId = "";
|
||||
|
||||
/** jikip 用户 ID(余量查询参数)。 */
|
||||
private String jikipUserId = "";
|
||||
}
|
||||
Reference in New Issue
Block a user