taskflow: task read roles and caller-filtered actions

Đang mở
#374 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@mushrafmim đang làm issue này rồi.

Từ ngày 3/11/2026.

  • #378 của @mushrafmim — đang mở

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
12/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go, sql
Lĩnh vực
backend, databases

Hướng nghiên cứu

Start with the proposal's design rather than code: it spans the task template schema, the gorm task store (new task_roles table written in the same transaction as the task row), GetTaskRenderInfo and GetAllTasks, renderer.Facts, and ZoneViewAssembler.Assemble. Work is already under way in linked PR 375, so review that first. Done means the proposal's access_roles and Commands filtering are implemented as specified, with the breaking changes handled.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Type/New Feature
Problem

taskflow has no way to say who may open a task, or to show a caller only the actions they may take.

  • Who may open a task. GetTaskRenderInfo and GetAllTasks return any task to any caller. A host that wants to gate a task, or list only the caller's tasks, has nothing in the task record to match against. It ends up keeping its own task-to-role mapping outside taskflow, and that mapping can drift from the templates.
  • What a caller may do. The PRE_RESUME authz extension decides on the server which commands a caller may issue. The zoneview renderer, however, keeps a handle whenever its command is legal in the current state. A caller who may see a section but not act on it still gets its actions, which the server rejects only when they submit.
Proposed Solution

Keep the policy in the host. taskflow stores what the templates declare and forwards what the host has resolved. The two parts are independent and ship as separate PRs.

  1. Task read roles (#375). Task templates already carry read.roles (#377), an optional list of opaque role strings:

    { "id": "apply", "workflow_id": "apply-flow", "render_config_id": "apply-render", "read": { "roles": ["applicant", "reviewer"] } }
    

    StartTask copies them to the task as TaskRecord.ReadRoles. The gorm store writes them to a task_roles (task_id, role, case_id) table in the same transaction as the task row, so a task never exists without its roles. A host gates and lists tasks by joining its own record of who holds each role on (case_id, role). The roles never change after the task starts. A template with no read roles writes no rows.

  2. Caller-filtered actions (#378). renderer.Facts gains Commands map[string]bool: the commands the caller may issue, which the host resolves from the same rules its authz extension enforces. The zoneview renderer keeps a handle only if its command is legal in the state and allowed for the caller, so a visible section with no allowed actions renders read-only. nil means nothing is filtered. ZoneViewAssembler.Assemble takes a Caller{Claims, Commands}.

What each mechanism decides:

Question Decided by
Can the caller open the task? read.roles, recorded in task_roles (#375)
Can the caller see a section? visibleWhen.requireClaim (unchanged)
Can the caller take an action? the commands authz allows, enforced on submit and reflected in Facts.Commands (#378)

Breaking changes: hosts must create task_roles before upgrading (#375), and Assemble's signature changes (#378). Templates need no change.

Alternatives
  • A separate, required access_roles field on the task template. Dropped once #377 added read.roles: two lists of who may read a task would drift from each other.
  • Roles with a permission each (e.g. {"role": "read&write"}). Rejected. Whether a role may write is already answered per command by the authz rules, and a second answer would drift from them. It's also coarser: "write" can't tell approve apart from reject.
  • Roles as an array column on the task row. Rejected. Listing a caller's tasks needs a join and a B-tree index on (case_id, role), which a row per role gives directly, along with idempotent inserts through the primary key.
  • Keep the task-to-role mapping only in the host. Possible, but the host would have to re-read templates and keep its copy in step with the task's manifest version. Recording roles when the task starts, in the same transaction as the row, avoids both.
Ngôn ngữ chính
Go
Star
6
Fork
8
Merge trung bình
21 giờ 36 phút
Pull request đã merge (30 ngày)
42

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của OpenNSW/core

Tất cả issue của OpenNSW/core

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.