[taskflow] Give hosts a task's read roles so they can check access to its detail

Aperta
#384 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@mushrafmim ci sta già lavorando.

Dal 3/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Type/Improvement
Current Limitation

Taskflow never decides who may read a task, so a host checks access itself. A listing goes through TaskManager.GetTasks with TaskFilter.Roles, which matches the caller's roles against the task's read roles in SQL. A single task's detail, TaskManager.GetTaskRenderInfo(ctx, taskID), checks nothing. frontend-guide.md says the host must first check "that the caller holds one of the task's read roles (TaskRecord.ReadRoles, stored in taskflow_task_roles) in the task's case", because a caller can request any task ID directly.

No TaskManager method lets a host do that check:

  • TaskView, which GetTaskRenderInfo returns, has neither the task's CaseID nor its read roles.
  • In the store, GetTask and GetTaskByWorkflowID fill every TaskRecord field except ReadRoles. The roles live in taskflow_task_roles, and the TaskRecord doc says "the read methods leave this field empty: a host that needs a task's roles reads them where InitTask stored them".

So the only way to do the required check is to query taskflow_task_roles directly. That ties every task-detail endpoint to the table, its columns and its name, outside the TaskManager API that hosts otherwise use. Hosts call TaskManager, not the store, which is the persistence port only the manager calls. A change to the table changes the host without a compile error, and a host that forgets the check exposes every task to anyone who can guess an ID.

Suggested Improvement
  1. Store: GetTask and GetTaskByWorkflowID return ReadRoles, loaded from taskflow_task_roles by task_id (the leading column of its primary key). GetTasks keeps leaving it empty, like Data: its role filter already runs in SQL, and a listing doesn't need the roles.

  2. Hosts: expose the check through TaskManager, in one of two ways:

    • a. Match roles in GetTaskRenderInfo (preferred). The host passes the roles the caller holds, as it does for GetTasks, and taskflow matches them by name, the same rule as TaskFilter.Matches. For example:
      GetTaskRenderInfo(ctx context.Context, taskID string, roles []string) (TaskView, error)
      
      It returns ErrTaskNotFound (or a dedicated error) when the caller holds none of the task's read roles. Taskflow still never decides who holds a role. A listing and a detail read then apply the same rule in one place, and the check can't be skipped by forgetting it. As with TaskFilter.Roles, a role the caller holds in only some cases must be passed only for a task in one of those cases; the host can check the case against TaskView.CaseID (see b).
    • b. Return the inputs and let the host match. Add CaseID and ReadRoles to TaskView, and the host compares them with its own record of who holds each role. TaskView is what hosts send to clients, so decide whether these fields go over the wire or are tagged json:"-".

    Either way, update frontend-guide.md and integration-guide.md so no step tells a host to read taskflow_task_roles.

This is a breaking change if (a) changes GetTaskRenderInfo's signature; a new method alongside it avoids that.

Version

910de31

Additional Context
  • OpenNSW/core#383 makes hosts go through TaskManager for finding and listing tasks (GetTasks with the new step filter), and documents that hosts never call the store. This closes the same gap for a single task's access check.
  • If both land before the next release, TaskStore implementations change once for 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.