Skip to content

[authz] examples(devicecell/ordercell)HTTP 授权 contract-derived 迁移(#2355 续波 PR-A) #2486

Description

@ghbvf

现状

#2355(PR #2476)落地了 owner/self-scoped HTTP 授权 contract-derived 基座(endpoints.http.{resource,selfScoped} + 单一 RequirePermissionForContract funnel)并迁完 accesscore,但 examples(devicecell / ordercell)的 owner-scoped HTTP gate 仍手写在 slice handler,由 OWNER-SCOPED-GATE-EXACT-SET-01 的 scan 臂(TestOwnerScopedGate_ExactSet_01)冻结:

  • examples/iotdevice/cells/devicecell/slices/devicecommand/handler.go:4 个 path-param owner-scoped(dequeue/report/ack/extend-lease,RequirePermissionForResource("id", PermDeviceConsume()))+ 2 个 enqueue(coarse device:command)。
  • examples/todoorder/cells/ordercell/cell.go:owner-scoped get/confirm(PermOrderRead/Update)+ coarse list/create。

根因:三维——代码(gate 手写在 handler,未声明 contract overlay)/ 架构(基座已就绪,examples 未跟进,临时双机制)/ 历史(#2355 切割为「基座 + accesscore pilot」,examples 显式 defer 为续波 PR-A)。影响:examples 作为外部 Cell 作者范本,应示范 contract-derived 写法。

修复方向

照搬 accesscore 迁移模式(无框架改动,纯模板套用):

  • 最小:给 devicecommand 4 个 owner 契约加 resource: id + permission: device:consume、2 个 enqueue 加 device:command;ordercell 加对应 permission/resource。
  • 彻底:重生成(handler_gen 转 funnel + cellHTTPResolver)、删手写 gate、cell_init 接 resolver;OWNER-SCOPED-GATE-EXACT-SET-01 把 examples key 从 scan 臂移到 contract-derived 臂(ownerScopedGateContractDerivedSet);从 httpAuthModeMigrationLedger 删对应 examples 条目(order.*)。
  • 重构:无需(基座已是终态)。

注意:devicecell 近期被 #2444(per-device pending 上限 + enqueue 429)改动,迁移时基于最新 handler。

Files

  • examples/iotdevice/cells/devicecell/slices/devicecommand/handler.go
  • examples/iotdevice/cells/devicecell/cell.go
  • examples/todoorder/cells/ordercell/cell.go
  • contracts/http/device/command//v1/contract.yaml、contracts/http/order//v1/contract.yaml
  • tools/archtest/owner_scoped_gate_01_test.go(scan→contract-derived 臂迁移)
  • framework/kernel/metadata/authz_mode.go(ledger 删 examples 条目)

Source

PR #2476 finding F11(产品维度);Discovered via /ship #2355(续波 PR-A,ADR 202606201500-2355 §后续)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-auth认证 Authn + 授权 AuthzbacklogBacklog item — automation trigger 入 projectcx-2Cx2 改动量:同包 ≤5 文件pri-p2Priority P2type-refactor重构

    Projects

    • Status
      In review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions