fix(framework): ApiRequestFilter 纳入 /open-api 路径,修复 open-api 多租户拦截缺失

TenantSecurityWebFilter 继承 ApiRequestFilter,之前 shouldNotFilter 仅匹配
/admin-api 和 /app-api,导致 /open-api 请求跳过租户校验,DB 层
getRequiredTenantId() 抛 NPE。现在补上 openApi prefix,外部系统需传
tenant-id Header。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lzh
2026-03-13 12:02:02 +08:00
parent 6e56dcb6a2
commit 2a20f7a89f

View File

@@ -8,7 +8,7 @@ import org.springframework.web.filter.OncePerRequestFilter;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
/** /**
* 过滤 /admin-api、/app-api 等 API 请求的过滤器 * 过滤 /admin-api、/app-api、/open-api 等 API 请求的过滤器
* *
* @author 芋道源码 * @author 芋道源码
*/ */
@@ -21,7 +21,10 @@ public abstract class ApiRequestFilter extends OncePerRequestFilter {
protected boolean shouldNotFilter(HttpServletRequest request) { protected boolean shouldNotFilter(HttpServletRequest request) {
// 只过滤 API 请求的地址 // 只过滤 API 请求的地址
String apiUri = request.getRequestURI().substring(request.getContextPath().length()); String apiUri = request.getRequestURI().substring(request.getContextPath().length());
return !StrUtil.startWithAny(apiUri, webProperties.getAdminApi().getPrefix(), webProperties.getAppApi().getPrefix()); return !StrUtil.startWithAny(apiUri,
webProperties.getAdminApi().getPrefix(),
webProperties.getAppApi().getPrefix(),
webProperties.getOpenApi().getPrefix());
} }
} }