Skip to content

[Feature] Portal 管理页支持查看和撤销Open API Token的具体授权 #5647

Description

@LinyingHong

Is your feature request related to a problem? Please describe.

一个 Open API Token(Consumer)在 Apollo Portal 中支持授权多个 App / Namespace,这在多个项目共用一个集成 token 的场景下很常见。但目前 Portal 管理页 /open/manage.html(仅超级管理员)存在两个痛点:

  1. 看不见 token 授权了哪些 App / Namespace。 列表页只显示归属 AppId、名称、允许创建应用、限流 QPS、部门、Owner,没有任何入口能查看这个 token 到底被授予了对哪些 App / Namespace 的管理权限。
Image

当前 Consumer 列表页:只有 "Grant Permission" 和 "Delete" 两个操作,看不到已授权范围。

  1. 无法撤销单条 App / Namespace 授权。 "Grant Permission" 弹窗是只增不删的;要移除某条授权,目前唯一的办法是删除整个 Consumer,这会连同 token 一起销毁,所有下游调用方都必须重新对接。

在实际运维中,一个 token 随着时间会累积很多 App 的授权,目前没有安全的方式去精细收敛权限。

Describe the solution you'd like

保留现有的 "Grant Permission" 添加流程不变,在其之上增加查看 + 撤销能力:

UI 改造

  • 列表页每一行新增 "View Permissions" 按钮。
  • 点击后弹出面板,列出该 token 当前持有的所有授权(App 级与 Namespace 级,Namespace 级带上 namespaceNameenv)。
  • 每一行末尾提供 "Revoke" 按钮,带二次确认。
  • 修改场景通过"撤销 + 重新使用现有 Grant Permission 添加"完成,不引入独立的 edit 语义

Portal Management API 新增

  1. GET /openapi/v1/consumers/{token}/authorized-apps
    返回该 Consumer 当前所有 App / Namespace 授权列表。底层的 ConsumerService#findAppIdsAuthorizedByConsumerId(long) 已存在,目前只服务于 token 持有方自查的 /openapi/v1/apps/authorized,尚未开放给管理端。
  2. DELETE /openapi/v1/consumers/{token}/roles
    参数:type=AppRole|NamespaceRoleappId、可选 namespaceName、可选 env。撤销一条授权;Namespace 级撤销会同时移除对应的 ModifyNamespaceReleaseNamespace 绑定。

两个新接口和 UI 入口继续沿用现有 Consumer 管理面的权限边界,通过 @unifiedPermissionValidator.isSuperAdmin() / isRootUser 限制超级管理员,并写入 ConsumerAudit

按仓库 AGENTS.md 的契约先行要求,会先在 apolloconfig/apollo-openapi 提 spec PR,主仓再 bump apollo.openapi.spec.url 并在 PortalManagementController 实现生成的接口。

Describe alternatives you've considered

  • 删除并重建整个 Consumer(当前唯一 workaround):会丢失 token、影响所有下游、无法只收敛某一个 App。

Additional context

底层数据模型已经支持一个 token 授权多个 App:授权关系记录在 ConsumerRole (consumerId, roleId) 表中,roleId 指向该 App 的 Master+{appId} 或该 Namespace 的 ModifyNamespace+... / ReleaseNamespace+... role。缺的只是管理端的查询、撤销接口,以及 UI 展示。

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions