## 现状 `auth.WithAuthorizer`(PDP 注入)是导出函数。cell 经 `RouteGroup.Middleware` 注册的 middleware 执行序在 `RequirePermission` route policy **之前**: - `runtime/auth.wrapMountGuards`(route.go:187-211)把 `RequirePolicy(Policy)` 包在 handler **内层**。 - `runtime/http/router.nativeMuxAdapter.Handle`(router.go:1713-1714)`chain(handler, a.middlewares...)` 把 cell 的 `RouteGroup.Middleware` 包在 **外层**。 因此一段业务 cell middleware 调 `auth.WithAuthorizer(ctx, alwaysAllowPDP)` 即可换掉自己声明门禁读到的 PDP、静默 neuter 该门禁。零信任多 cell 平台下,框架应保证「声明了的 RequirePermission gate 真的 gate」。 #2022 的 `AUTH-WITHAUTHORIZER-CALLER-01`(Medium archtest)已在**治理层**闭合 in-repo/exemplar 可枚举向量(任何 cell 调 WithAuthorizer 触 CI 红)。但**真正 external(不被 archtest 扫描)的 cell** 仍可走此 seam——只有结构性 reorder 能根除。 ## 修复方向 让框架 auth gate(RequirePermission + BootstrapAuth + CallerCell)在 cell `RouteGroup.Middleware` **之前**执行,使 cell middleware 无法在 gate 读 authorizer 前改 ctx。三级方案种子: - minimal:`nativeMuxAdapter.Handle` 把 framework gate wrap 在 `a.middlewares` 之外(gate 最外层),cell middleware 内移。 - thorough:把 gate 提升为 listener/route-group 级 framework-owned middleware,与 cell middleware 显式分层(framework-before-cell 不变式 + archtest 守卫)。 - refactor:route 装配引入 phase 化 middleware 顺序模型(framework-pre / cell / framework-post),由类型/装配 API 强制 framework gate 不可被 cell 前置。 风险:可能误伤合法 cell pre-handler middleware(需审计现有 RouteGroup.Middleware 用法);改 route 装配语义需回归全 listener 路由测试。 ## Files - `framework/runtime/auth/route.go:187-211`(wrapMountGuards) - `framework/runtime/http/router/router.go:1703-1725`(nativeMuxAdapter.Handle) - `framework/runtime/bootstrap/phases_http.go:387-468`(authorizerInjector / default middleware) ## Source Discovered via /ship #2022(PR feature/2022-withauthorizer-caller-funnel)。#2022 的 caller funnel 闭合治理层向量,本 issue 是其结构性根除(external cell 残留盲区)。
Activity