Skip to content

Access control

Authentication

The WES API requires an access token of a trusted identity provider (OpenID Connect), sent as a bearer token, for all operations on runs:

curl -X GET "http://localhost:8090/ga4gh/wes/v1/runs" \
  -H "Authorization: Bearer <token>" -H "Accept: application/json"

GET /service-info, the specification (/ga4gh/wes/v1/openapi.json) and the Swagger UI (/ga4gh/wes/v1/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), as problem details.

proWES accepts only tokens that:

  • are access tokens as per RFC 9068 (typ header at+jwt), not, e.g., ID tokens;
  • are issued by one of the trusted issuers (security.auth.issuers, the iss claim), and verified with the issuer's keys (from its OpenID Connect discovery document);
  • are for one of the configured audiences (security.auth.audience, the aud claim), i.e., were issued to one of the apps that call proWES (e.g., its front ends, by their client IDs);
  • if security.auth.clients is set, were obtained by one of these clients (the client_id claim, or azp if there is none);
  • have not expired.

The base config trusts no issuer, so all tokens are rejected (and a warning is logged on startup) until a deployment sets its issuers and audiences, e.g., in a config overlay:

security:
  auth:
    issuers:
      - https://login.example.org/oidc/
    audience:
      - my-portal-client-id

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 for all settings (e.g., several issuers, claims from the user info endpoint).

Tokens of clients are never passed on to the WES instances that runs are forwarded to: proWES authenticates there with credentials of its own (see Credentials of WES instances).

Authentication can be switched off only by changing disable_auth of api.specs in the configuration: then anyone who can reach proWES can start runs, and runs have no owner (every client sees all runs). Don't do this outside local tests.

Credentials of WES instances

proWES authenticates at the WES instances that runs are forwarded to with credentials of its own, never with those of its clients, as the auth of their entries in custom.wes.backends says (see WES instances):

  • client_credentials (the default): an access token of proWES's own client at an identity provider (OAuth 2.0 client credentials grant), sent as a bearer token. The identity provider is set in custom.wes.client_credentials (its issuer, whose discovery document names the token endpoint, or the token_endpoint itself); the client ID and secret come from the environment variables PROWES_CLIENT_ID and PROWES_CLIENT_SECRET (e.g., from a Secret), never from the configuration. The Docker Compose setup passes both from the host to the app and the Celery worker; with the Helm chart, set them from a Secret with prowes.extraEnv (see WES instances). With audience_parameter (resource, RFC 8707, or audience), each WES instance gets a token for its own audience: the audience of its entry, else its URL.
  • basic: HTTP Basic credentials, from the environment variables that basic.username_env and basic.password_env of the entry name; a transitional mode for WES instances that don't accept tokens.
  • none: no credentials, for WES instances that require none.

WES instances discovered in a service registry get the credentials of their registry entry (client_credentials or none). Without audience_parameter, all WES instances get the same token, so each of them could replay it at the others: set audience_parameter (if the identity provider supports it) when WES instances aren't equally trusted, e.g., with registry entries, or give registry entries auth: none; proWES warns on startup about registry entries that would share the token. The credentials are looked up for each request, from the entry of the WES instance in the current backend list: proWES sends no request (and no credentials) to WES instances that the list no longer yields, e.g., after their entry was removed; their runs can't be tracked or canceled any more (see WES instances). Tokens are cached until shortly before they expire (refresh_before, 60 seconds by default). The service infos of WES instances, read to choose where runs go, are read without credentials.

The app refuses to start if the environment variables of the credentials it needs aren't set, or if auth: client_credentials is used without an identity provider (the Celery worker, which isn't checked on startup, then fails to track runs: set the variables for both); it warns about WES instances with auth: basic or auth: none, and about URLs with scheme http, over which credentials are sent unencrypted. A request without available credentials (e.g., the identity provider is unavailable while proWES has no valid token) is not sent, and not tried again: forwarding the run fails, and the worker counts a failed poll (runs fail after custom.post_runs.polling_attempts of them, e.g., during a longer outage of the identity provider); see Failed requests to WES instances.

Run ownership

Each run belongs to the caller that created it: the subject of its token (the claim security.auth.claim_identity, by default sub), namespaced by the token's issuer as <namespace>|<subject>, so that equal subjects of different issuers are different owners. The namespace is the issuer itself (e.g., https://login.example.org/oidc/|alice), also if only one issuer is trusted, so that owners stay the same when another issuer is trusted later (as FOCA namespaces subjects). Set namespace of an issuer (entries of security.auth.issuers as {issuer: <url>, namespace: <name>}) for a shorter one, or an empty one to keep its subjects bare; changing it later orphans the runs stored so far. Namespaces must differ between issuers and must not contain | (FOCA refuses such settings on startup), and neither must issuers without namespace, which are the namespace of their subjects: set a namespace for an issuer whose URL contains |. Owners are stored with each run (user_id) and taken from the token only, never from the request.

Callers list their own runs only (GET /runs), and only they read, query the status of and cancel a run (GET /runs/{run_id}, GET /runs/{run_id}/status, POST /runs/{run_id}/cancel); requests for runs of others get 403 Forbidden. Tokens without a subject claim are invalid (401); tokens whose subject can't own runs (an empty one, or a bare one containing |) get 403 Forbidden. Runs stored without owner (e.g., before authentication was switched on) can't be read by anyone. Roles, admins and sharing runs follow with access control (#48).