taskflow: task read roles and caller-filtered actions

Aperta
#374 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@mushrafmim ci sta già lavorando.

Dal 3/11/2026.

  • #378 di @mushrafmim — aperta

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
12/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
go, sql
Ambito
backend, databases

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
Go
Stelle
6
Fork
8
Merge medio
21h 36m
PR unite (30g)
42

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenNSW/core

Tutte le issue di OpenNSW/core

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.