Access control¶
Authentication¶
The TES API requires an access token of a trusted identity provider (OpenID Connect), sent as a bearer token, for all operations on tasks:
curl -X POST "http://localhost:8080/ga4gh/tes/v1/tasks" \
-H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
-d @task.json
GET /service-info, the specification (/ga4gh/tes/v1/openapi.json) and
the Swagger UI are public. Requests without a valid
token are rejected with 401 Unauthorized and a Bearer challenge
(WWW-Authenticate: Bearer, RFC 6750; with error="invalid_token" for
invalid tokens); requests with a valid token, but without the required role,
with 403 Forbidden (both as problem details).
proTES accepts only tokens that:
- are access tokens as per RFC 9068
(
typheaderat+jwt), not, e.g., ID tokens; - are issued by one of the trusted issuers (
security.auth.issuers, theissclaim), and verified with the issuer's keys (from its OpenID Connect discovery document); - are for one of the configured audiences (
security.auth.audience, theaudclaim), i.e., were issued to one of the apps that call proTES (e.g., its front ends, by their client IDs); - if
security.auth.clientsis set, were obtained by one of these clients (theclient_idclaim, orazpif there is none); - have not expired.
If your identity provider sets another typ header on its access tokens,
list it in security.auth.token_types; if it sets none, disable the check
with security.auth.verify_token_type: false (see FOCA's authentication
options).
Roles¶
| Role | May |
|---|---|
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) and get its provenance (Provenance) |
admin |
get anonymous totals of the resources that all tasks used (Usage) and the records as execution reports (Execution reports); not the tasks of others nor their provenance or usage, nor the access control rules (see 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
endpoint if listed in security.auth.userinfo_claims) are mapped to the
roles user and admin by security.access_control.group_mapping. Values
are matched exactly, so list each group whose members get a role, including
subgroups. The role owner is not mapped from groups: users get it on the
tasks they create (see Task ownership).
The roles and their permissions are the policies of
security.access_control.policies in the base config (see
FOCA's access control),
named rules (users-create-tasks, authenticated-list-tasks,
owners-get-cancel-tasks, owners-get-provenance,
authenticated-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:
security:
access_control:
policies:
authenticated-list-tasks: null
users-list-tasks: [p, user, /ga4gh/tes/v1/tasks, (GET)|(HEAD)]
owners-get-cancel-tasks: [p, owner, "/ga4gh/tes/v1/tasks/:id", (GET)|(HEAD)]
(users-list-tasks is a name of your own; names only need to be unique.)
The subject "*" of a rule (as in authenticated-list-tasks) stands for
any authenticated caller.
The access control model of proTES (pro_tes/access_control/model.conf)
differs from FOCA's reference model in that the role admin may not do
everything: admins only have the rights that rules give them.
Task ownership¶
The user who creates a task (the sub claim of the access token, or the
claim set in security.access_control.claim_identity) becomes its owner:
GET /taskslists only the tasks of the caller, also for admins, and is allowed for every authenticated caller (ruleauthenticated-list-tasks), so that former users still find their tasks (also everyone else whom your identity providers issue tokens for proTES, who see an empty list; setauthenticated-list-tasks: nulland add a rule for the roleuserto refuse them, see Roles);-
GET /tasks/{id}andPOST /tasks/{id}:cancelare allowed for the owner only; everyone else gets403 Forbidden, also admins and for unknown tasks, so that responses don't tell which tasks exist. The owner gets404 Not Foundfor a task that was deleted from the database. -
GET /tasks/{id}/provenanceis allowed for the owner only (ruleowners-get-provenance); every other caller gets403 Forbidden, also admins and for unknown tasks, as forGET /tasks/{id}(requests without a valid access token get401 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). -
GET /pluginsandGET /plugins/{plugin_id}(what users may choose per task, see Choices of clients) are allowed for the roleuser(rulesusers-list-pluginsandusers-get-plugins); everyone else gets403 Forbidden, also admins without the roleuser, and requests without an access token401 Unauthorized.
Tasks are not shared with other users, and admins can't read or cancel the
tasks of others through the API, nor give themselves access (the
permissions API is off): tasks and their logs may hold
sensitive data, and users' entitlements to access data can't be passed on
to others. Operators handle stuck or abusive tasks through the
infrastructure (see Abusive tasks).
Owners keep access to their tasks if they lose the role user (e.g., when
their group membership is revoked): they still list, read and cancel them,
but can't create tasks then.
Owners are stored as resource-scoped roles of FOCA (g2 rules in the
collection policy_rules) on the task and on its cancellation, e.g., for
task ABC123:
g2, user:<sub>, owner, /ga4gh/tes/v1/tasks/ABC123
g2, user:<sub>, owner, /ga4gh/tes/v1/tasks/ABC123:cancel
The task document records its owner, too (user_id), e.g., for operators
looking for the tasks of a user (see Operations).
Each task adds two rules, and FOCA loads all rules on each request (and
creating or listing tasks loads them a few more times), so the time of each
request grows with the number of tasks (see FOCA's notes on
scaling).
As every authenticated caller may list tasks, limit request rates at the
ingress if your identity providers issue tokens for proTES to many people.
"Authenticated" means any valid token with a subject from a trusted issuer:
also tokens of clients that are not service clients,
proTES' own client among them, and, with
security.auth.verify_audience: false, tokens issued for other services.
Such callers see only the tasks of their own subject: none, unless that
subject created tasks (e.g., a user whose token was issued for another
service).
Ownership is taken from the caller's own token only: a user's token makes
the user the owner, and a service client's own token the client (see
Service clients). Nobody can create tasks for someone
else: a service client may name the user it acts for, but only for
accounting and audit; the client stays the owner (see Acting for
users). proTES refuses to start if FOCA's
security.auth.on_behalf_of_header is set, as it would let a client list
the tasks of the users it names.
New tasks never get the identifier of a stored task, or of a task that owner roles are left on (e.g., of a deleted task), so that nobody gets access to the task of someone else with the same identifier.
A list replaces all rules of the base config. The configured rules replace
the stored ones atomically on each startup; if an overlay leaves no rules,
the stored ones are removed.
The role admin comes only from groups in group_mapping: the startup
check doesn't count g rules of the policies or of the permissions API.
Service clients¶
Apps that run tasks for themselves, not for a user (e.g., a workflow engine
with a client-credentials token of its own, or automated tests), can be
allowed as service clients. This is off by default: without
security.auth.service_clients, tokens of clients are handled as before,
and their own client IDs are not accepted audiences. Each allowed client is
listed explicitly, by its issuer and client ID, and gets the role user,
e.g., for a client my-engine of the identity provider of the example
below (see Deployment settings):
security:
auth:
audience:
- my-portal-client-id
# if the identity provider puts only the client's own ID into `aud`
# of its client-credentials tokens
- my-engine
service_clients:
- client_id: my-engine
issuer: https://login.example.org/oidc/
access_control:
client_mapping:
my-engine: user
A token is the service token of a listed client if it was issued by the
client's issuer (iss), to the client (client_id, or azp without it),
and its subject (sub) is the client ID (or the client's subject, see
FOCA's authentication
options). With
such a token, the client:
- creates tasks, and becomes their owner as a client (
client:<client ID>: owner roles such asg2, client:my-engine, owner, /ga4gh/tes/v1/tasks/<id>, anduser_id: "client:my-engine"in the task document); - lists, reads and cancels its own tasks, and reads their provenance;
- sees no tasks of others, and others (users, other clients, admins) don't
see its tasks; a user whose
subequals a client ID is another owner; - gets nothing beyond: no admin rights, and no access to the tasks of a user it names (see Acting for users).
Its tasks are relayed to the TES instances as all tasks, with proTES' own
credentials (see Credentials of TES
instances); the client's token is not
passed on. Limits of the tasks per user count the tasks of each client as
those of client:<client ID>, and accounting records them under that owner.
Audience. Some identity providers put only the client's own ID into the
audience (aud) of its client-credentials tokens, so that ID must be an
accepted audience (security.auth.audience, or the audience of the
client's issuer); proTES warns on startup for clients whose ID isn't. As
that audience would also accept other tokens for the client, e.g., users'
tokens obtained by it (by login, or by token exchange, after which some
identity providers keep the exchanging client in aud), proTES accepts the
ID of a service client as audience only for that client's own service
tokens: other tokens whose only accepted audiences are IDs of service
clients are rejected on all endpoints (401, with an invalid_token
challenge). Tokens for the other audiences are not affected.
Groups. Service tokens with groups (in the group claim,
claim_groups) are rejected likewise (401), also without audience
validation, as the roles of their groups (group_mapping) would be added
to the role user of the client, e.g., admin; proTES logs a warning
naming the client and the claim. Many identity providers put no groups into
client-credentials tokens, and proTES doesn't request user info for them.
Where they do (e.g., for groups of a client's service account), remove the
groups from the client's tokens at the identity provider (its group
memberships or the mapper of the claim) before listing the client.
proTES refuses to start if a service client has no explicit issuer (client
IDs are unique per issuer only), isn't mapped to the role user or is
mapped to another role, may act for users (on_behalf_of) without the
header to name them (see Acting for users), or is
proTES' own client (PROTES_CLIENT_ID), whose tokens TES instances get.
The allowed clients are logged on startup.
Tasks belong to the caller of their token, also when a client names the user it acts for. To make users the owners of the tasks that an app submits for them (e.g., a workflow engine), token exchange (RFC 8693) is the way: a user's token exchanged for proTES' audience is a user token, so its tasks belong to the user, and the service client role isn't needed for it.
User identity at TES instances¶
proTES relays tasks with its own credentials (see Credentials of TES
instances), so TES instances see proTES,
not the user. TES instances that need to know who submitted a task, for
accounting or audit, can get the identity of the submitter as task tags.
This is off by default, per entry of custom.tes.backends: set
identity_tags: true on a TES instance (type: ga4gh-tes), or on a
registry (type: ga4gh-service-registry) for all TES instances it lists:
custom:
tes:
backends:
- type: ga4gh-tes
url: https://tes.example.org
identity_tags: true
- type: ga4gh-service-registry
url: https://registry.example.org/ga4gh/registry/v1
identity_tags: true
client_credentials:
issuer: https://login.example.org/oidc/
Each task relayed to such a TES instance carries these tags (in all TES versions; tags are part of TES 1.0 and 1.1):
| Tag | Value |
|---|---|
submitter.iss |
Issuer of the user's token (for a user named by a service client, the client's issuer) |
submitter.sub |
The user's subject: the sub claim of the token, or the user named by a service client (see Acting for users); missing for service clients acting for nobody |
submitter.sub_source |
token if submitter.sub comes from the user's own token, service_client if a service client named the user; missing without submitter.sub |
submitter.client_id |
Client that the token was issued to (client_id, else azp), e.g., a web portal or a workflow engine |
proTES always sends the sub claim, not the claim of
security.access_control.claim_identity (e.g., an e-mail address), and
never names, e-mail addresses, groups or tokens. Values are strings of at
most 1024 bytes (UTF-8), as the gateway tags; longer values
are left out, not cut. The tags are not under the gateway's prefix
(gateway.), which relayed tasks never carry, so that another gateway
behind proTES accepts them. The identity doesn't pass through a proTES
behind proTES, though: that one drops the tags, and names the proTES in
front of it, a client of it, in its own.
Tags of clients under submitter. are never relayed, to any TES instance,
whether it gets the identity or not, so that nobody can pass another
identity off as the one proTES sends. proTES stores the task with the
client's tags as sent.
Use at TES instances. The tags are for accounting and audit only (who
used how much, whom to ask about a task), never for authorization: they
are data of the task, and any caller can send tags under submitter. to a
TES instance directly. A TES instance can rely on them only for tasks of a
gateway that it knows sets them (by the gateway's client ID, or API key),
and even then only to attribute tasks, never to grant access. Policies of a
TES instance that see the tags of tasks (e.g., Poiesis passes them to its
authorization service) must not use them.
Personal data. The subject of a user is personal data, even if it is a
persistent pseudonymous identifier of the identity provider: with
identity_tags, it is disclosed to that TES instance (and, for a registry,
to every TES instance that its admins verify). Before switching it on, as
the operator of proTES, make sure you may disclose it to them, and name them
and the purpose in your privacy notice; each TES instance decides on its
own purposes, retention (TES instances keep tasks, with their tags, until
they are deleted) and access, and needs a privacy notice that covers the
identifiers it receives, for accounting and audit only.
Acting for users¶
A service client that submits tasks for users (e.g., a workflow engine
running a user's workflow) may name the user, so that TES instances that
get the identity of submitters can attribute the task to the user. This is
off by default; allow it per client with on_behalf_of: true (FOCA's
setting), and set the header that names the user
(custom.controllers.post_task.on_behalf_of_header):
security:
auth:
service_clients:
- client_id: my-engine
issuer: https://login.example.org/oidc/
on_behalf_of: true
custom:
controllers:
post_task:
on_behalf_of_header: X-On-Behalf-Of
The client then sends the subject (sub) of the user at the client's
issuer in that header with POST /tasks, e.g., X-On-Behalf-Of:
<sub>. proTES:
- accepts the header only from service clients with
on_behalf_of: true, with their own service tokens; everyone else who sends it, users included, gets403 Forbidden; - answers
400 Bad Requestto an empty user, one with surrounding whitespace, one that can't be stored (e.g., over 1024 characters), or one that is not ASCII (servers read header values as Latin-1); proTES takes the user verbatim, without decoding (e.g., percent-encoding), so thatsubmitter.subis the user's subject, and users whose subject is not ASCII can't be named; - stores the user with the task (
acting_for, as owners are stored, see Task owners), and in its usage record (see below); FOCA logs the client and the user on levelDEBUG; - sends it as
submitter.sub, withsubmitter.sub_source: service_client, to the TES instances that get the identity of submitters.
The client stays the owner of the task: it lists, reads and cancels it,
the task counts against its limits and is accounted to it; the named user
gets no access to the task, and doesn't see it in their list. With
accounting of resource
usage, the usage record of
the task also holds the named user (acting_for), which is personal data
as the owner is, and kept and deleted as the records are (see Usage
records): the named user gets the totals of
those tasks, and the client can split its totals by named user (GET
/usage, see Usage); admins get only anonymous totals, and
execution reports leave it out. The header is read on POST /tasks only,
and ignored on other requests. proTES checks nothing about the named user
(that the user exists, may run tasks, or consented): the client is trusted
to name the user whose request it handles, so allow only clients that
check their users themselves. proTES refuses to start if a client may act
for users without the header, or the header is set without such a client.
FOCA's own header (security.auth.on_behalf_of_header) stays refused.
Permissions API¶
FOCA's permissions
API
(/admin/access-control/permissions), which lists, adds, changes and
deletes access control rules at runtime, is off
(security.access_control.api_enabled: false; its paths get 404 Not
Found, also for admins). It accepts any rule of the model, also owner
roles on the tasks of others (g2 rules) and rules for the paths of tasks,
so whoever may use it could read and cancel any task, with its inputs,
outputs, environment and logs. The rules come from the config (and its
overlays) only, which are stored in the database (collection policy_rules
of taskStore, or of the database in MONGO_DBNAME if set) on each
startup.
Admins (the role admin) see no task content, only:
- anonymous totals of the resources that all tasks used, withheld below a
minimum number of tasks (
GET /usage, see Usage); - the usage records as execution reports, without user identifiers
(
GET /usage/reports, see Execution reports).
Not the provenance of the tasks of others either (GET
/tasks/{id}/provenance, see Provenance): it is for
the owner of the task only.
To change rules, change the config (see Roles) and restart proTES. Rules stored earlier through the API stay in the database and in effect: check them when upgrading (see Upgrading).
If you need the API, turn it on with a config overlay, together with the rules that let admins use it:
security:
access_control:
api_enabled: true
policies:
admins-list-add-permissions: [p, admin, /admin/access-control/permissions, (GET)|(POST)]
admins-manage-permissions: [p, admin, "/admin/access-control/permissions/:id", (GET)|(PUT)|(DELETE)]
proTES then logs a warning on startup, as admins could make themselves
owners of the tasks of others; FOCA logs each request to the API. Give the
role admin only to operators trusted with the data of the tasks, and keep
the API off the internet: the Helm chart's Ingress (or HTTPRoute, or Route)
routes all paths to the app, so block /admin/ in front of the cluster
(see Exposing the app).
Deployment settings¶
Which identity providers are trusted, for which audiences, and which groups
have which role is deployment configuration: the base config has no
defaults, and the app refuses to start without trusted issuers, without an
audience (unless security.auth.verify_audience is false, which accepts
tokens for any app, or each issuer has an audience of its own, see below)
and without a group mapped to the role admin (unless
security.access_control.require_admin is false). Set them in a config
overlay, e.g.:
security:
auth:
issuers:
- https://login.example.org/oidc/
audience:
- my-portal-client-id
# if the identity provider releases groups via user info only
userinfo_claims:
- groups
access_control:
claim_groups: groups
group_mapping:
compute-users: user
compute-admins: admin
Issuers may also be maps of the issuer (issuer) and settings of their own
(FOCA's IssuerConfig): the namespace of their users' subjects
(namespace; by default the issuer, also if only one issuer is
trusted; "" keeps the subjects bare; see Task
owners), and an audience, a group claim
(claim_groups) and userinfo_claims that replace the global ones for
the issuer's tokens (unless unset or null), e.g.:
security:
auth:
issuers:
- issuer: https://login.example.org/oidc/
audience:
- my-portal-client-id
- issuer: https://other.example.org/
audience:
- my-portal-client-id
# take no groups from this issuer's tokens
claim_groups: ""
Group claim values are not namespaced: take groups only from issuers that
cannot issue each other's groups, and set claim_groups: "" for the others
(see FOCA's authentication
options).
The app logs the groups of each role on startup, and warns if no group has
the role user (nobody can create tasks then) and if group_mapping is
set without claim_groups (no group gets a role then). FOCA also warns on
every startup that group_mapping is set without
security.access_control.keep_group_subjects, so that rules granted to
groups (group:<value>) don't apply: this warning is harmless for proTES,
whose rules grant roles only, and is expected (see
foca#577). It refuses to start
if access control is not enabled and enforced
(security.access_control.enabled and enforce), as users could access
the tasks of others then. The Docker Compose setup
uses config.dev.yaml, which accepts tokens for any audience and requires no
admins; set your issuer and groups there. For local tests without an
identity provider, the smoke test brings a fake one.
Credentials of TES instances¶
proTES authenticates at TES instances with credentials of its own, never
with those of its callers: the access tokens of requests are not forwarded,
and no credentials of callers are stored or queued for the Celery worker.
How proTES authenticates is set for each entry of custom.tes.backends, by
auth (TES instances discovered in a service registry get the auth of
the registry's entry, client_credentials or none):
client_credentials(the default): with an access token of proTES itself, which it gets from its identity provider with the OAuth 2.0 client credentials grant (RFC 6749, section 4.4). TES instances accept tokens of proTES' client (e.g., by theclient_idclaim of the token). proTES caches the token, and fetches a new one shortly before it expires (refresh_beforeseconds, at most half its lifetime), also in the Celery worker, which polls tasks for hours;basic: with HTTP Basic credentials from environment variables, whose names are set inbasic(username_env,password_env). This is a transitional mode for TES instances that don't accept tokens yet, and will be removed once all of them do;api_key: with an API key of proTES at the TES instance, for TES instances that don't accept tokens of proTES' client, but API keys, e.g., Poiesis (see API keys of TES instances). For configured TES instances only: registries can't hand one key to all the TES instances that they list. This is a transitional mode too, until proTES exchanges the tokens of its users per TES instance;none: without credentials, e.g., for TES instances on an internal network that need none.
Requests to TES instances get only these credentials: none from a .netrc
file of the environment (~/.netrc, or the file of NETRC), which
requests would otherwise add to requests without credentials, put in
place of proTES' access token, and look up again after redirects. Redirects
within the same host and port keep the credentials, as do redirects from
http to https on the default ports; all other redirects drop them (also
API keys in headers other than Authorization).
Proxies and CA certificates of the environment (e.g., HTTPS_PROXY,
REQUESTS_CA_BUNDLE) still apply to configured TES instances. Requests to
the identity provider of proTES don't get credentials from .netrc either,
except after redirects of its discovery document.
The client ID and secret of proTES are read from the environment variables
PROTES_CLIENT_ID and PROTES_CLIENT_SECRET, and Basic credentials and API
keys from the variables named in the config, e.g., set from Kubernetes
Secrets; they are never part of the config or the database. The app refuses
to start if one of them is not set for a TES instance that needs it, and
warns of each TES instance with basic, api_key or none. Set the TES
instances and the identity
provider of proTES in a config overlay, e.g.:
custom:
tes:
backends:
- type: ga4gh-tes
url: https://tes.example.org
- type: ga4gh-tes
url: https://tes.example.com
auth: basic
basic:
username_env: TES_EXAMPLE_COM_USERNAME
password_env: TES_EXAMPLE_COM_PASSWORD
- type: ga4gh-tes
url: https://poiesis.example.net
auth: api_key
api_key:
key_env: TES_POIESIS_API_KEY
client_credentials:
# The token endpoint is that of the issuer's OpenID Connect discovery
# document (`token_endpoint` sets it instead)
issuer: https://login.example.org/oidc/
# Scope of the tokens, if the identity provider needs one
scope: null
# Parameter that names the TES instance in token requests, for a
# token per TES instance: `resource` (RFC 8707) or `audience`; by
# default (null), all TES instances get the same token (see below)
audience_parameter: null
# `client_secret_basic` (HTTP Basic) or `client_secret_post`
auth_method: client_secret_basic
The Docker Compose setup passes PROTES_CLIENT_ID and
PROTES_CLIENT_SECRET of the host to the app and the Celery worker; with
the Helm chart, set them (and the variables of Basic credentials) from a
Secret with protes.extraEnv (see the chart's README). The Celery worker
checks the credentials on startup, too.
The client of proTES is registered at the identity provider for the client
credentials grant; it is a client of its own, not the client of the front
ends whose tokens proTES accepts (security.auth.audience). By default,
all TES instances with client_credentials get the same token, so each of
them could use it at the others until it expires: configure only TES
instances that you trust, and keep the lifetime of the tokens short. This
includes the TES instances discovered in service registries, whose entries
default to auth: client_credentials: every TES instance that a registry's
admins verify gets the token, and could use it at the other TES instances
of proTES, also at the configured ones. Use registries whose admins you
trust as much as the TES instances that you configure yourself, or set
auth: none for registry entries whose TES instances don't need the token
of proTES; or request a token per TES instance (see Tokens per TES
instance). On startup, proTES logs which TES
instances get its token (TES backends with access tokens of proTES: ...,
with (each for its own audience, requested with `resource`) for tokens
per TES instance), with the registries whose verified TES instances get it
(those verified by registry <url>). Service infos, read for the TES
versions of TES instances (and the API paths of discovered ones), get no
credentials, unless
custom.tes.probe_with_token is set, which sends the token also to TES
instances that a task isn't routed to (see TES
versions). Tasks are only
forwarded to configured TES instances, and to those discovered in the
service registries of custom.tes.backends (only verified ones, see
Discovery in a service
registry); plugins
can only choose among them (see Plugins). The credentials of
TES instances are not passed to plugins, and the plugin API doesn't let
them choose other credentials for a TES instance than its own; in the
forward phase, they may only drop them (none), e.g., to send
credentials of their own. Plugins are fully trusted code, though: they run
in the processes of proTES and can read its credentials (see
Plugins). Keep TES instances in the list until their tasks have finished:
tasks of TES instances that are no longer configured can't be tracked or
canceled (their state becomes UNKNOWN, and is tracked again once the TES
instance is configured again).
URLs of TES instances, registries and of the identity provider must use
https (url_schemes of each entry of custom.tes.backends, and
custom.tes.url_schemes for the identity provider); allow http for local
tests only, as tokens and credentials are sent unencrypted then. URLs of TES
instances must not have credentials (https://user:password@host).
Credentials in the URLs of inputs and outputs of tasks
(https://user:password@host/...) are not accepted either: such tasks are
rejected with 400 Bad Request, or, if
custom.controllers.post_task.url_credentials is strip, the credentials
are removed before the task is stored and forwarded (see
Tasks). Credentials that plugins add are
always removed. The headers Authorization, Cookie and
Proxy-Authorization of callers are left out of what plugins see, but
plugins get the caller's validated access token (FOCA's Principal.token,
e.g., for token exchange): enable only plugins that you trust with it.
proTES doesn't tell TES instances on whose behalf it forwards tasks yet: they only see proTES. Tags with the identity of the user are planned, once their names are agreed with other services.
Tokens per TES instance¶
With custom.tes.client_credentials.audience_parameter, proTES requests a
token of its own for each TES instance, which names the TES instance as the
audience of the token, so that a TES instance that checks the audience
refuses the tokens of the others. The parameter of the token request is
resource (resource indicators, RFC
8707) or audience (as some
identity providers name it); its value is the audience of the TES
instance's entry, as written, or else its URL (normalized, e.g., without
trailing slash). TES instances discovered in a service registry always get tokens
for their base URLs: the URLs that the registry lists, normalized and
without the TES API path (e.g., https://tes.example.org for
https://tes.example.org/ga4gh/tes/v1/). For resource, an audience of
an entry must be an absolute URI without query and fragment (e.g.,
urn:example:tes); for audience, it can be any string without
surrounding whitespace (e.g., the client ID of the TES instance). proTES
caches the tokens per audience (entries with the same audience share a
token), and refuses to start if an entry sets audience without auth:
client_credentials, or while audience_parameter is not set. Errors of
token requests name the audience, in quotes (No access token for resource
'<audience>' from <token endpoint>: ...).
custom:
tes:
backends:
# Gets a token for `https://tes.example.org`
- type: ga4gh-tes
url: https://tes.example.org
# Gets a token for the audience of the entry
- type: ga4gh-tes
url: https://tes.example.com
audience: urn:example:tes
# Each verified TES instance gets a token for its URL
- type: ga4gh-service-registry
url: https://registry.example.org/ga4gh/registry/v1
client_credentials:
issuer: https://login.example.org/oidc/
audience_parameter: resource
This protects TES instances from each other only if all of the following hold:
- the identity provider issues tokens for the requested audience (in the
audclaim of the token, or in what its token introspection returns). Identity providers that set the audience of a client once, at its registration, ignore the parameter (all TES instances get tokens with that audience again) or refuse the request (invalid_target, logged asNo access token for <parameter> '<audience>' from <token endpoint>, and tasks aren't forwarded to the TES instance); - each TES instance accepts only tokens for its own audience, e.g., its URL
as proTES sends it, or the
audienceof its entry.
proTES doesn't check the audience of the tokens it gets, which may be opaque to it. Test the setup before relying on it: decode a token of the identity provider for one TES instance, and check that the other TES instances refuse it.
API keys of TES instances¶
Some TES instances don't accept tokens of proTES' client, but API keys: e.g.,
Poiesis, which
checks an entitlement claim that client-credentials tokens don't carry. For
these, an entry with auth: api_key gives proTES an API key of an account
at the TES instance; api_key says where proTES reads it, and how it sends
it:
custom:
tes:
backends:
- type: ga4gh-tes
url: https://poiesis.example.net
auth: api_key
api_key:
# Environment variable with the key (or `<key_env>_FILE`, see below)
key_env: TES_POIESIS_API_KEY
# Header of the key (default): `Authorization: Bearer <key>`, as
# Poiesis expects it; other headers (e.g., `X-API-Key`) carry the
# key as it is
header: Authorization
- Where the key comes from: the environment variable
key_env, or the file named in the variable<key_env>_FILE(e.g.,TES_POIESIS_API_KEY_FILE=/run/secrets/poiesis-api-key, a mounted Secret), as FOCA reads its own credentials; setting both is an error. A final line break is dropped (e.g., of a Secret created from a file). proTES reads the key for each request, and never writes it to the config, the logs, the database or the task documents, nor passes it to plugins. Keys must be visible ASCII characters (no spaces or line breaks). Unknown keys ofapi_key(e.g., the key itself as a value) stop the app on startup, and the error doesn't show their values. - Checks on startup: the app and the Celery worker refuse to start if
neither variable is set for a TES instance with
auth: api_key(named with the other missing credentials), or if the key can't be used (both set, the file can't be read, or invalid characters). The messages name the TES instance by its URL, never the key, nor the names of the variables (a key pasted askey_envby mistake may be a valid variable name): look upkey_envof that TES instance in the config. Missing keys are listed asthe API keys of TES backends <url> (the variables that their `key_env` names, or their `_FILE` variables), keys that can't be used asTES backend <url>: API key: ...; requests that find no usable key fail withTES backend <url>: API key .... Each TES instance with an API key is logged with a warning (TES backend <url>: API key (`auth: api_key`, header <header>) ...). - Which requests: every request to the TES instance: creating, getting
and canceling tasks (also by the Celery worker, which polls them), and its
service info if
custom.tes.probe_with_tokenis set (otherwise service infos are read without credentials). Redirects to other hosts or ports drop the key, in any header. - Only configured TES instances: registry entries can't have
auth: api_key, as every TES instance that a registry lists would get the key. Give each TES instance a key of its own, so that a TES instance can't use the key at another one. - Task ownership at the TES instance: the TES instance sees all tasks of proTES as tasks of the key's account (in Poiesis, a key acts as the user who minted it), not of the users who created them. Users still only see their own tasks in proTES (see Task ownership), but quotas, accounting and access control of the TES instance apply to the key's account as a whole, and anyone with access to that account at the TES instance sees all tasks that proTES sent there. Use an account that is meant for proTES, not a personal one.
- Rotating the key: create a new key at the TES instance, update the
Secret, and restart the app and the Celery worker if the key comes from
the environment variable (with the Helm chart,
kubectl rollout restart deploy/<app> deploy/<app>-worker -n <namespace>,<app>as in its README, Names and labels, e.g.,protesfor the releaseprotes); with<key_env>_FILE, the file is read for each request, so the new key is used once the file is updated. Then revoke the old key at the TES instance (see its docs, e.g., Poiesis' API keys). Keys may expire: rotate them in time, as requests with an expired key fail with401 Unauthorized(new tasks then go to other TES instances, and the tasks at that TES instance can't be tracked or canceled until a valid key is set).
API keys are a transitional mode until proTES exchanges the tokens of its users for tokens of each TES instance (OAuth 2.0 token exchange, RFC 8693); TES instances then see the users again, and no shared key is needed.