Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions docs/access-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ options](https://foca.readthedocs.io/en/latest/configuration/auth/)).
| --- | --- |
| `user` | create tasks (`POST /tasks`) |
| any authenticated caller | list their own tasks (`GET /tasks`), also without a role |
| `owner` (of a task) | read and cancel the task (`GET /tasks/{id}`, `POST /tasks/{id}:cancel`) |
| `admin` | get the resources that tasks used per user ([Usage](api.md#usage)) and as execution reports ([Execution reports](api.md#execution-reports)), and the provenance of tasks ([Provenance](api.md#provenance)); not the tasks of others, nor the access control rules (see [Permissions API](#permissions-api)) |
| `owner` (of a task) | read and cancel the task (`GET /tasks/{id}`, `POST /tasks/{id}:cancel`) and get its provenance ([Provenance](api.md#provenance)) |
| `admin` | get the resources that tasks used per user ([Usage](api.md#usage)) and as execution reports ([Execution reports](api.md#execution-reports)); not the tasks of others nor their provenance, nor the access control rules (see [Permissions API](#permissions-api)) |

Roles are given to groups of the identity provider: the values of the claim
`security.access_control.claim_groups` (from the token, or from the user info
Expand All @@ -58,11 +58,11 @@ The roles and their permissions are the policies of
`security.access_control.policies` in the base config (see
[FOCA's access control](https://foca.readthedocs.io/en/latest/access-control/)),
named rules (`users-create-tasks`, `authenticated-list-tasks`,
`owners-get-cancel-tasks`, `owners-get-provenance`, `admins-get-provenance`,
`admins-get-usage`, `admins-get-usage-reports`, `users-list-plugins` and
`users-get-plugins`): a config overlay adds, changes or removes (`null`)
single rules by name, e.g., rules that let only users list their tasks, and
owners only read them:
`owners-get-cancel-tasks`, `owners-get-provenance`, `admins-get-usage`,
`admins-get-usage-reports`, `users-list-plugins` and `users-get-plugins`):
a config overlay adds, changes or removes (`null`) single rules by name,
e.g., rules that let only users list their tasks, and owners only read
them:

```yaml
security:
Expand Down Expand Up @@ -97,12 +97,13 @@ claim set in `security.access_control.claim_identity`) becomes its owner:
tasks, so that responses don't tell which tasks exist. The owner gets
`404 Not Found` for a task that was deleted from the database.

- `GET /tasks/{id}/provenance` is allowed for the owner and for admins
(rules `owners-get-provenance` and `admins-get-provenance`); everyone else
gets `403 Forbidden`. The provenance holds no inputs or logs of the task,
only which plugins and TES instances processed it (see
[Provenance](api.md#provenance)); remove `admins-get-provenance` (`null`
in an overlay) to keep it from admins.
- `GET /tasks/{id}/provenance` is allowed for the owner only (rule
`owners-get-provenance`); every other caller gets `403 Forbidden`, also
admins and for unknown tasks, as for `GET /tasks/{id}` (requests without
a valid access token get `401 Unauthorized`). The provenance holds no
inputs or logs of the task, but tells which plugins and TES instances
processed it and when, i.e., details of someone's task (see
[Provenance](api.md#provenance)).

- `GET /plugins` and `GET /plugins/{plugin_id}` (what users may choose per
task, see [Choices of clients](plugins.md#choices-of-clients)) are allowed
Expand Down Expand Up @@ -396,9 +397,11 @@ Admins (the role `admin`) see no task content, only:
- the resources that tasks used, per user, also per user that service
clients ran tasks for (`GET /usage`, see [Usage](api.md#usage));
- the same as execution reports, without user identifiers (`GET
/usage/reports`, see [Execution reports](api.md#execution-reports));
- the provenance of a task: which plugins and TES instances processed it
(`GET /tasks/{id}/provenance`, see [Provenance](api.md#provenance)).
/usage/reports`, see [Execution reports](api.md#execution-reports)).

Not the provenance of the tasks of others either (`GET
/tasks/{id}/provenance`, see [Provenance](api.md#provenance)): it is for
the owner of the task only.

To change rules, change the config (see [Roles](#roles)) and restart
proTES. Rules stored earlier through the API stay in the database and in
Expand Down
16 changes: 8 additions & 8 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ control](access-control.md)).
| `POST /tasks` | Create a task: proTES forwards it to a TES instance (see [Tasks](#tasks)) and returns its own identifier of the task. |
| `GET /tasks` | List the caller's tasks, newest first, one page at a time (`page_size`, at most `max_page_size` of the [config](configuration.md#tasks), and `max_page_size_full` tasks, of at most `max_page_bytes_full` bytes, for the view `FULL`; `page_token` from `next_page_token` of the previous page, which is empty on the last page), optionally only those whose name starts with `name_prefix` (taken literally; matched against the name of the task as submitted, before plugins may have renamed it), by `state`, or by tags (`tag_key` and `tag_value`, in pairs, taken literally: a key without a value, or with an empty one, matches any value of that tag; a task must match all pairs; more values than keys are rejected with `400 Bad Request`; needs MongoDB 5.0 or later). |
| `GET /tasks/{id}` | Get a task of the caller, with its state as last tracked from the TES instance. |
| `GET /tasks/{id}/provenance` | proTES extension: get the provenance of a task, for its owner and for admins (see [Provenance](#provenance)). |
| `GET /tasks/{id}/provenance` | proTES extension: get the provenance of a task, for its owner only (see [Provenance](#provenance)). |
| `GET /usage` | proTES extension: get the resources that the tasks of each user used, for admins, if accounting is enabled (see [Usage](#usage)). |
| `GET /plugins` | proTES extension (FOCA's plugin listing): list the plugins and presets that the caller may choose for its tasks, and the limits, for users; the default pipeline only for callers who may choose pipelines (see [Choices of clients](plugins.md#choices-of-clients)). |
| `GET /plugins/{plugin_id}` | proTES extension: describe a plugin that the caller may choose (`404 Not Found` otherwise). |
Expand Down Expand Up @@ -179,13 +179,13 @@ resolved pipeline (`pipeline.resolved`), e.g., shortened:
}
```

The owner of the task and admins may get it; everyone else gets
`403 Forbidden`, also for unknown tasks (see [Access
control](access-control.md#task-ownership)); admins get `404 Not Found` for
unknown tasks. Tasks without provenance (e.g.,
created by earlier versions) give `404 Not Found`. The record holds no
inputs, logs, IP addresses, tokens, header values or claims: plugins'
changes are recorded as paths and hashes only.
Only the owner of the task may get it; every other caller gets `403
Forbidden`, also admins and for unknown tasks, as for `GET /tasks/{id}`
(see [Access control](access-control.md#task-ownership)); requests
without a valid access token get `401 Unauthorized`. Tasks without
provenance (e.g., created by earlier versions) give `404 Not Found`. The
record holds no inputs, logs, IP addresses, tokens, header values or
claims: plugins' changes are recorded as paths and hashes only.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ outcome, reason, remote identifier, times) and the final reason, if no TES
instance accepted the task. The record is stored with the task (after
routing), and replaced, with the attempts, once a TES instance accepted the
task (or may have, `SYSTEM_ERROR`). Records hold no IP addresses, tokens,
header values or claims, and take at most 1 MiB. Owners and admins get
header values or claims, and take at most 1 MiB. Only owners get
them with `GET /tasks/{id}/provenance` (see [Provenance](api.md#provenance)),
and tasks carry a summary in their tags (`gateway.*`, see [Gateway
tags](api.md#gateway-tags)). Tasks created by earlier versions have none.
Expand Down
38 changes: 32 additions & 6 deletions docs/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@ changes](#unreleased-changes)).

## Unreleased changes

**Provenance for owners only (breaking change, rule removed):** `GET
/tasks/{id}/provenance` is now allowed for the owner of the task only:
admins get `403 Forbidden`, like everyone else who doesn't own the task,
also for unknown tasks (before, admins got the provenance of any task, and
`404 Not Found` for unknown ones). The rule `admins-get-provenance` is
removed from the base config: the provenance tells which plugins and TES
instances processed a task and when, i.e., details of someone else's
task, which admins must not see (see [Task
ownership](access-control.md#task-ownership)). The stored rule is removed
on startup, with the other configured rules. Admins keep usage and usage
reports. Scripts or dashboards that read the provenance with an admin's
token must use the owner's token instead (e.g., a service that created the
tasks on its own client). Overlays that remove the rule
(`admins-get-provenance: null`, as these docs suggested before) stop the
start, with FOCA's error naming the unknown rule: drop that entry. An
overlay that still sets the rule adds it again, as a rule of your own; drop
it. Custom lists of `security.access_control.policies` (which replace the
rules of the base config) must drop it too, or admins keep the access.
During a rolling upgrade, instances of earlier versions that start store
the rule again, until the last of them is replaced.

**Stale polls fenced (behaviour change, new field):** each run of a poll
claims the tracking of its task with a token of its own, stored in
`tracking.claim`, and only the run that claimed it last stores unfinished
Expand Down Expand Up @@ -868,10 +889,12 @@ Check each item; the sections below have the details.
(see [TES instance list](#tes-instance-list)).
5. **Access control rules:** custom lists of
`security.access_control.policies` must add the new rules
`users-list-plugins`, `users-get-plugins`, `owners-get-provenance` and
`admins-get-provenance`, or users get `403` (see [Task
provenance](#task-provenance)); overlays that change rules by name keep
them.
`users-list-plugins`, `users-get-plugins` and `owners-get-provenance`,
or users get `403` (see [Task provenance](#task-provenance)); overlays
that change rules by name keep them. The rule `admins-get-provenance`
of 0.4.0 is removed again in later versions: leave it out, or admins
can read the provenance of any task (see [Unreleased
changes](#unreleased-changes)).
6. **Database:** proTES uses new collections in the database of the tasks:
`plugin_builds`, `pipelines` and `failed_runs` (see [Task
provenance](#task-provenance)) and `plugin_store` (see [Plugin
Expand Down Expand Up @@ -1128,7 +1151,9 @@ empty.

Owners and admins get the provenance with `GET /tasks/{id}/provenance`
(rules `owners-get-provenance` and `admins-get-provenance` of the base
config; custom lists of `security.access_control.policies` must add them).
config; custom lists of `security.access_control.policies` must add them;
admins no longer get it since the [unreleased
changes](#unreleased-changes)).
New tasks have the gateway tags of FOCA (`gateway.pipeline_source`,
`gateway.backend`, ...; see [Gateway tags](api.md#gateway-tags)), served
with the task: clients that submit a fetched task again must drop the tags
Expand Down Expand Up @@ -1260,7 +1285,8 @@ API specifications (`api.specs`) and access control rules
(`security.access_control.policies`) of the base config are named entries
(the spec `tes`; rules `users-create-list-tasks` (split in 0.8.0, see
[To version 0.8.0](#to-version-080)),
`owners-get-cancel-tasks`, `owners-get-provenance`, `admins-get-provenance`,
`owners-get-cancel-tasks`, `owners-get-provenance`, `admins-get-provenance`
(removed, see [Unreleased changes](#unreleased-changes)),
`users-list-plugins`, `users-get-plugins`, `admins-list-add-permissions`
and `admins-manage-permissions`; the last two removed in 0.8.0, see
[To version 0.8.0](#to-version-080)), which overlays change by name (see
Expand Down
4 changes: 2 additions & 2 deletions pro_tes/access_control/model.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
# Unlike FOCA's reference model (`resource_role_model.conf`), the role `admin`
# may not do everything: admins only have the rights that rules give them
# (provenance and usage, cf. `config.yaml`), so that nobody but the owner of
# a task can read or cancel it.
# (usage, cf. `config.yaml`), so that nobody but the owner of a task can read
# or cancel it, or get its provenance.
#
[request_definition]
# sub - accessing entity (prefixed user identifier, or role from group claims)
Expand Down
8 changes: 4 additions & 4 deletions pro_tes/api/additions.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ paths:
proTES extension: get the provenance of a task, as recorded by the
plugin engine of FOCA when the task was created and forwarded, with
the plugin builds and the pipeline that it refers to. For the owner
of the task and for admins.
of the task only, not for admins.
operationId: GetTaskProvenance
parameters:
- name: id
Expand All @@ -71,16 +71,16 @@ paths:
$ref: '#/components/schemas/TaskProvenance'
403:
description: >-
The caller is neither the owner of the task nor an admin (also
for unknown tasks, which admins get as 404).
The caller is not the owner of the task (also admins, and for
unknown tasks, as for GetTask).
content:
application/json:
schema:
$ref: '#/components/schemas/ProblemDetails'
404:
description: >-
The task has no provenance (e.g., created by an earlier version
of proTES), was deleted, or (for admins) doesn't exist.
of proTES) or was deleted.
content:
application/json:
schema:
Expand Down
14 changes: 7 additions & 7 deletions pro_tes/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ security:
issuers: []
# Access control: users (the role `user`) may create tasks; every
# authenticated caller may list their own; the user creating a task becomes
# its owner, and only owners may read and cancel a task, also after losing
# the role `user`. Admins (the role `admin`) may only read the provenance
# of tasks and the usage per user, not the tasks of others. Roles are given
# to groups of the identity provider (values of the claim `claim_groups`)
# by `group_mapping`, e.g.:
# its owner, and only owners may read and cancel a task and get its
# provenance, also after losing the role `user`. Admins (the role `admin`)
# may only read the usage per user and the execution reports, not the
# tasks of others nor their provenance. Roles are given to groups of the
# identity provider (values of the claim `claim_groups`) by
# `group_mapping`, e.g.:
# claim_groups: groups
# group_mapping:
# compute-users: user
Expand Down Expand Up @@ -96,9 +97,8 @@ security:
authenticated-list-tasks: [p, "*", /ga4gh/tes/v1/tasks, (GET)|(HEAD)]
# `POST` is cancellation (`/tasks/{id}:cancel`)
owners-get-cancel-tasks: [p, owner, "/ga4gh/tes/v1/tasks/:id", (GET)|(HEAD)|(POST)]
# the provenance of a task, also for admins (no inputs or logs)
# the provenance of a task, for its owner only (not for admins either)
owners-get-provenance: [p, owner, "/ga4gh/tes/v1/tasks/:id/provenance", (GET)|(HEAD)]
admins-get-provenance: [p, admin, "/ga4gh/tes/v1/tasks/:id/provenance", (GET)|(HEAD)]
# the resources that tasks used, per user (`custom.accounting`)
admins-get-usage: [p, admin, /ga4gh/tes/v1/usage, (GET)|(HEAD)]
# the same records as execution reports, without user identifiers
Expand Down
4 changes: 2 additions & 2 deletions pro_tes/ga4gh/tes/task_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,8 @@ def _update_records(self, run: PipelineRun, db_document: DbDocument) -> None:
def get_task_provenance(self, id: str) -> dict[str, Any]:
"""Get the provenance of a task, with its references expanded.

Only owners of the task and admins may get it (enforced by the
policies). The builds of the plugins that ran and default and
Only owners of the task may get it, not admins either (enforced by
the policies). The builds of the plugins that ran and default and
preset pipelines are stored once, by hash (cf.
:py:class:`foca.plugins.ProvenanceStore`); they are added to the
record (`builds`, `pipeline.resolved`), unless it has them
Expand Down
Loading
Loading