fix: PUT/POST新接口加入鉴权拦截器+uploadScript版本号自增
This commit is contained in:
@@ -74,9 +74,15 @@ public class ScriptController {
|
||||
if (script == null || script.isBlank()) {
|
||||
return ApiResponse.error(400, "script body is required");
|
||||
}
|
||||
// 版本号由服务端管理
|
||||
// 版本号递增
|
||||
SiteConfig latest = configService.getLatestConfig(siteId);
|
||||
int nextVersion = 1;
|
||||
if (latest != null) {
|
||||
try { nextVersion = Integer.parseInt(latest.getVersion()) + 1; }
|
||||
catch (NumberFormatException ignored) {}
|
||||
}
|
||||
Long submitterId = (Long) request.getAttribute("accountId");
|
||||
SiteConfig config = configService.submitConfig(siteId, "1", script, submitterId);
|
||||
SiteConfig config = configService.submitConfig(siteId, String.valueOf(nextVersion), script, submitterId);
|
||||
return ApiResponse.success(Map.of("version", config.getVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,9 @@ public class WebConfig implements WebMvcConfigurer {
|
||||
registry.addInterceptor(hmacAuthInterceptor)
|
||||
.addPathPatterns("/api/v1/configs/*/submit", "/api/v1/sites/*/submit",
|
||||
"/api/v1/sites/*/access-result", "/api/v1/sites/*/error-log",
|
||||
"/api/v1/sites/*/pages", // PUT 页面配置
|
||||
"/api/v1/scripts/*", // PUT 上传脚本
|
||||
"/api/v1/risk-rules/*", // POST 提交风险规则
|
||||
"/api/v1/admin/**", "/api/v1/account/**");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user