Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b7a6810
feat(engine): map identity-provider tokens to temporal roles
hasithaa Nov 2, 2026
d46dbf7
feat(engine): secure the frontend and choose services from runtime.toml
hasithaa Nov 2, 2026
eceab09
docs: add the user guide and require it in every change
hasithaa Nov 2, 2026
3f54bb2
feat(engine): discover the identity provider's key set from its issuer
hasithaa Nov 2, 2026
0b2bc09
docs: create the WorkflowKind search attribute with the namespace
hasithaa Nov 2, 2026
109b680
fix(engine): require tls with tokens and protect the internal frontend
hasithaa Nov 3, 2026
72b53a6
docs: note the sqlite limits in the user guide
hasithaa Nov 3, 2026
2af8490
test: accept the temporal cli 1.9 wording of a tls refusal
hasithaa Nov 3, 2026
946453d
fix(engine): fetch identity provider keys only over https
hasithaa Nov 4, 2026
f735a1d
docs: note that postgresql verifies the database host name
hasithaa Nov 4, 2026
fa2b1fa
fix(engine): refuse identity provider redirects to plain http
hasithaa Nov 4, 2026
11cbf82
fix(engine): honour --service on a node whose profiles name only api
hasithaa Nov 4, 2026
0f0da0f
fix(engine): read key sets without the unapproved go-jose module
hasithaa Nov 4, 2026
9e2d3cd
fix(engine): default the internode server name to the certificate's
hasithaa Nov 4, 2026
3d6bec0
fix(engine): encrypt membership traffic and settle the internode name
hasithaa Nov 4, 2026
4caeda0
fix(engine): harden key set reads and check when tokens were issued
hasithaa Nov 4, 2026
ff4c232
docs: keep the schema tool's password out of the command line
hasithaa Nov 4, 2026
1406417
fix(engine): keep the keys when a key set response has none
hasithaa Nov 4, 2026
3b75593
test: join two secured nodes into one engine
hasithaa Nov 4, 2026
90f7080
Merge remote-tracking branch 'upstream/main' into runtime/secure-engine
hasithaa Nov 5, 2026
a8d23a5
test: start the second sqlite node again after SQLITE_BUSY
hasithaa Nov 5, 2026
c84221e
test: stop an engine that never reported serving
hasithaa Nov 5, 2026
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
12 changes: 12 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ Go 1.26.8 or later; the toolchain line in `go.work` and `engine/go.mod` selects
These are requirements, not suggestions. A change that misses one is not done.

1. **Document it in the same commit.**
- **User guide first.** Anything a user can see or do (install, configure, secure, run, connect, upgrade,
troubleshoot) updates `docs/user-guide/` with complete, working instructions: every step, command, key and
default a user needs, tried on a real build, not described from the code. Add a page when a task has none,
and update `docs/user-guide/reference/runtime-toml.md` for every configuration key.
- **Check the whole guide, not only your page.** Before opening the PR, read every page the change touches and
the pages that link to them, and make commands, key names, defaults, ports and file paths agree with the code
and with each other. A PR that leaves another page wrong is not done.
- A new or changed feature updates its page in `docs/features/` (create it from `docs/features/TEMPLATE.md`).
- A design change updates `docs/guides/ARCHITECTURE.md` or adds a decision record in `docs/decisions/`.
- A new or changed command, flag, configuration key or port updates the README, `docs/guides/DEVELOPING.md`
Expand Down Expand Up @@ -117,6 +124,11 @@ These are requirements, not suggestions. A change that misses one is not done.

## Documentation

- `docs/user-guide/` is for the people who install and run the runtime. It is the source of the Workflow Runtime
section of the WSO2 Integrator documentation (planned under `manage/workflow-runtime/` in wso2/docs-integrator,
shaped like its ICP section), so write it that way: front matter (`title`, `description`, `keywords`),
task-oriented pages, numbered steps, `:::info`/`:::tip`/`:::caution` admonitions, plain Markdown (no MDX
imports), links relative to the page. No internal plans, issue numbers or code internals.
- `docs/guides/` explains the system: `ARCHITECTURE.md` (components and how they connect), `DEVELOPING.md`
(build, run, debug), `TESTING.md` (test layers and how to add tests).
- `docs/features/` has one page per feature, from `TEMPLATE.md`: what it does, configuration, behavior, limits,
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Status: early development. The engine builds and runs; the launcher, Manager and

Documentation: [architecture](docs/guides/ARCHITECTURE.md), [developing](docs/guides/DEVELOPING.md),
[testing](docs/guides/TESTING.md), [features](docs/features/README.md), [decisions](docs/decisions/).

Installing and running the runtime: the [user guide](docs/user-guide/README.md).
Contributors and coding agents: read [AGENTS.md](AGENTS.md) first.

## Build
Expand Down
24 changes: 21 additions & 3 deletions distribution/conf/runtime.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The runtime's configuration. [engine] and [database] are read by workflow-engine (docs/features/runtime-config.md);
# the other tables are illustrative until their components arrive.
# The runtime's configuration. [runtime] profiles, [engine] and [database] are read by workflow-engine
# (docs/features/runtime-config.md); the other tables are illustrative until their components arrive.
[runtime]
profiles = ["all"] # or e.g. ["history"], ["manager"]
profiles = ["all"] # or e.g. ["frontend"], ["history", "matching"], ["worker"]

[engine]
# Listen on every interface and tell other nodes and clients which address reaches this one.
Expand All @@ -10,6 +10,24 @@ profiles = ["all"] # or e.g. ["history"], ["manager"]
# historyShards = 512 # fixed after the first start
logLevel = "info"

# TLS on port 7233 and tokens from your identity provider (docs/features/engine-security.md).
# [engine.tls]
# certFile = "conf/certs/engine.crt"
# keyFile = "conf/certs/engine.key"
#
# [engine.auth]
# type = "jwt"
# issuer = "https://idp.example.com/oauth2/token" # its key set is discovered; or set jwksUrls
# rolesClaim = "groups"
#
# [[engine.auth.rules]]
# value = "workflow-admins"
# namespace = "*"
# role = "admin"

# [engine.metrics]
# prometheusAddress = "0.0.0.0:9464"

[database]
type = "postgresql" # postgresql | mysql | sqlite
host = "db.example.com"
Expand Down
1 change: 1 addition & 0 deletions docs/features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ in the same commit ([AGENTS.md](../../AGENTS.md#rules-for-every-change)). Start
|---|---|
| [Engine](engine.md) | Available |
| [Runtime configuration](runtime-config.md) | Available |
| [Engine security](engine-security.md) | Available |
117 changes: 117 additions & 0 deletions docs/features/engine-security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Engine security

Status: available · since 0.1.0 (in development)

## What it does

Secures the engine's frontend (port 7233), the endpoint integrations connect to, without the Manager: TLS on the
connection, and tokens from the customer's own identity provider mapped to Temporal's namespace roles.

## Configuration

### `[engine.tls]`

| Key | Default | Meaning |
|---|---|---|
| `certFile`, `keyFile` | off | The frontend's certificate and key (PEM). Clients connect with TLS and trust its CA |
| `clientCaFile` | off | Require client certificates signed by this CA (mutual TLS) |
| `[engine.tls.internode]` `enabled` | `false` | TLS between the engine's services and nodes |
| `[engine.tls.internode]` `certFile`, `keyFile` | the frontend's | Certificate the services present to each other |
| `[engine.tls.internode]` `caFile` | required when enabled | CA that signs the internode certificates |
| `[engine.tls.internode]` `serverName` | the internode certificate's DNS name, when it has exactly one | Name every node verifies in the others' certificates. Temporal reaches the internal frontend through its membership resolver, which has no host name, so a name is always needed. Required when the certificate has no DNS name or several; an explicit name must be in the certificate (a DNS name, a wildcard match or an IP address) |

### `[engine.auth]`

| Key | Default | Meaning |
|---|---|---|
| `type` | `none` | `jwt` checks a bearer token on every call; `none` needs `--allow-no-auth` |
| `jwksUrls` | discovered from `issuer` | The identity provider's key set (JWKS) URLs, when it has no OpenID Connect discovery document; https, or http to a loopback host |
| `keyRefreshInterval` | `1m` | How often the key set is fetched again |
| `issuer` | | Required value of `iss`, and where the key set is discovered at start (`<issuer>/.well-known/openid-configuration`); `issuer` or `jwksUrls` is required |
| `audience` | not checked | Required value in `aud` |
| `subjectClaim` | `sub` | Claim naming the caller |
| `rolesClaim` | `permissions` | Claim holding the caller's groups, roles or scopes: a list, or a space- or comma-separated string; a dotted path reads a nested claim (`realm_access.roles`) |
| `valueRegex` | | Without rules: a regular expression with the named groups `namespace` and `role` |
| `leewaySeconds` | 0 | Clock skew allowed on `exp`, `nbf` and `iat` |
| `[[engine.auth.rules]]` `value`, `namespace`, `role` | | Grant `role` (`read`, `write`, `admin`) in `namespace` (or `*` for all) to callers whose roles claim holds `value` |

```toml
[engine.tls]
certFile = "conf/certs/engine.crt"
keyFile = "conf/certs/engine.key"

[engine.auth]
type = "jwt"
jwksUrls = ["https://cognito-idp.us-east-1.amazonaws.com/<pool>/.well-known/jwks.json"]
issuer = "https://cognito-idp.us-east-1.amazonaws.com/<pool>"
rolesClaim = "cognito:groups"

[[engine.auth.rules]]
value = "workflow-admins"
namespace = "*"
role = "admin"

[[engine.auth.rules]]
value = "orders-integration"
namespace = "default"
role = "write"
```

## Behavior

- **Three ways to read roles**, so any identity provider fits:
- Rules map the provider's group, role or scope names to namespace roles. Use them when the provider knows
nothing about namespaces, which is the usual case.
- Without rules, each value is Temporal's own `<namespace>:<role>` (for example `default:write`).
- `valueRegex` parses values in any other shape that carries both, such as `wf-default-write`.
- A role in namespace `*` (or Temporal's `temporal-system`) applies to every namespace and to cluster operations.
- Roles add up across values. `read` lets a caller list and describe; `write` adds starting and signalling
workflows and lets an integration's workers poll and complete tasks; `admin` adds namespace management. There is no
worker role: Temporal's default authorizer needs write to poll, so a `worker` rule is refused.
- `type = "jwt"` needs `[engine.tls]`, and, unless `bindAddress` is a loopback address, `[engine.tls.internode]`:
the internal frontend gives Temporal's own services system access without a token, so it and the other services'
ports accept only internode certificates.
- Internode TLS also turns on Temporal's `system.enableRingpopTLS` (passed as dynamic configuration at start), so the
membership ports, which list every node's address, take only internode certificates too.
- A `--service` list without `internal-frontend` on an engine with an authorizer logs a warning: another node must
run it.
- With neither `issuer` nor `audience`, those two claims are not checked; the start logs a warning. A token still
needs a valid signature from the key set, an expiry, a subject and a mapped role.
- With `issuer` and no `jwksUrls`, the start command reads the provider's OpenID Connect discovery document and uses
its `jwks_uri`; the document must name exactly the same issuer, and the engine does not start if it cannot read it.
- Key sets and discovery documents are fetched only over https (plain http only to a loopback host): a key set
replaced on the way would let anyone sign tokens the engine trusts. The same rule applies to every redirect, at start
and on each refresh, so the engine reads key sets itself (`jwtclaims.KeySet`); Temporal's key provider follows any
redirect.
- Each discovery document and key set read is limited to 1 MiB, and a redirect never goes from https to http. Only
RS256 and ES256 keys are kept, and only when their `use`, `key_ops` and `alg`, if published, allow verifying that
algorithm's signatures; an invalid entry never replaces a valid key with the same `kid`. A response without a `keys` member (an error page served with status 200) is refused, and the previous keys stay.
- Every token is checked for its signature, an expiry, the issuer and audience when set, and a subject; one issued in
the future (`iat` beyond `leewaySeconds`) is refused. A call without a token, or with a token that maps to no role,
is refused, except Temporal's health checks.
- Refusals return Temporal's generic "Request unauthorized"; the reason goes to the engine log.
- Temporal's own services reach the frontend through the internal frontend, which is not exposed to clients.
- Integrations connect with `mode = "SELF_HOSTED"`, the token in `authApiKey` and the CA in `authCaCert`
(`ballerina/workflow`).

## Limits

- Tokens must be signed with RS256 or ES256, as with Temporal's key provider.
- Clients present the token themselves; refreshing an expiring token is the client's job.
- Client certificates authenticate the connection only; roles still come from the token.

## Not covered yet

Roles from client certificate subjects, tokens issued by the Manager, and task-queue-scoped tokens.

## Tests

| Test | Covers |
|---|---|
| `engine/plugins/jwtclaims/discovery_test.go` | Discovery: the key set URL, another issuer or a trailing slash, no key set, a plain-http issuer or key set, invalid documents, unreachable providers; which URLs `CheckURL` accepts |
| `engine/plugins/jwtclaims/keyset_test.go` | Reading RS256 and ES256 keys, keeping them when a refresh fails, refreshing on the interval; a redirect to plain http refused for key sets and discovery, from https to loopback http refused, one to https followed; keys for encryption or another algorithm dropped, a bad entry not replacing a good key with the same ID; oversized key sets and sets without `keys` refused |
| `engine/plugins/jwtclaims/jwtclaims_test.go` | Temporal's format, rules on nested claims, scope strings, regex, issuer, audience, expiry, tokens issued in the future, forged and malformed tokens |
| `engine/internal/runtimeconfig/security_test.go` | TLS, auth and metrics mapping and every validation rule |
| `engine/internal/cli/cli_test.go` | A start with identity-provider auth; which claim mapper is built; the services the profiles and `--service` pass to the server, including `--service` with an `api`-only profile |
| `tools/internal/enginetest/cluster_test.go` | Two secured nodes on one SQLite file, one with frontend, matching and worker and one with frontend and history, form one engine: a workflow started through the first runs on the second's history, over TLS membership and internode TLS |
| `tools/internal/enginetest/security_test.go` | A real engine with TLS, internode mutual TLS and an OpenID Connect provider: an integration token starts and lists in its namespace; another namespace, a reader writing, no token, expired, forged, other-issuer and unmatched tokens, and plaintext are refused; the internal frontend refuses callers without an internode certificate and answers one with it; adding a search attribute works, which goes through the internal frontend with the derived server name; history, matching, worker and every membership port take TLS with a node certificate and refuse callers without one |
6 changes: 4 additions & 2 deletions docs/features/engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ the configuration defines one) in one binary built from the pinned Temporal serv
| `workflow-engine start --runtime-config <file>` | one of the two | Generate Temporal's configuration from `conf/runtime.toml` ([runtime configuration](runtime-config.md)) |
| `workflow-engine start --config-file <file>` | one of the two | Use a Temporal server configuration (YAML) as is |
| `workflow-engine render-config --runtime-config <file>` | | Print the configuration generated from `runtime.toml`, password hidden |
| `--service <name>` (repeatable) | `frontend`, `history`, `matching`, `worker`, plus `internal-frontend` when `services.internal-frontend` is configured | `frontend`, `internal-frontend`, `history`, `matching`, `worker` |
| `--service <name>` (repeatable) | From `runtime.toml`'s `[runtime] profiles`; with `--config-file`, `frontend`, `history`, `matching`, `worker`, plus `internal-frontend` when configured | `frontend`, `internal-frontend`, `history`, `matching`, `worker`; overrides the profiles |
| `--allow-no-auth` | off | Start without an authorizer; development and tests only |

## Behavior
Expand All @@ -39,7 +39,9 @@ the configuration defines one) in one binary built from the pinned Temporal serv

## Not covered yet

The engine endpoint, our authorizer, TLS and token configuration, and the launcher's profiles.
The engine endpoint, Manager-issued tokens, and the launcher's supervision and restart. TLS, identity-provider
tokens and profiles are covered by [engine security](engine-security.md) and
[runtime configuration](runtime-config.md).

## Tests

Expand Down
19 changes: 15 additions & 4 deletions docs/features/runtime-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ other, not both.
| `[database.tls]` `enabled`, `caFile`, `certFile` and `keyFile` (both or neither), `serverName` (MySQL only) | off | TLS to the database (PostgreSQL and MySQL; refused for SQLite) |
| `[database.tls]` `enableHostVerification` | `true` | Verify the server's certificate and host name; `false` turns verification off, which lets anyone between the engine and the database impersonate it |

### `[runtime]`

| Key | Default | Meaning |
|---|---|---|
| `profiles` | `["all"]` | What this node runs: `all` or `engine` (every engine service), `frontend` (with the internal frontend), `history`, `matching`, `worker`, and `api` (the API server; the engine starts nothing for it). Profiles combine |

Nodes find each other through the shared database, so a distributed deployment is the same `runtime.toml` on every
node with a different `profiles` and its own `broadcastAddress`.

### `[engine]`

| Key | Default | Meaning |
Expand All @@ -43,8 +52,10 @@ other, not both.
| `historyShards` | 512 (1 for SQLite) | Temporal history shards. **Cannot be changed after the first start** |
| `logLevel` | `info` | `debug`, `info`, `warn` or `error` |
| `[engine.ports]` `frontend`, `frontendHttp`, `internalFrontend`, `history`, `matching`, `worker` | 7233, 7243, 7236, 7234, 7235, 7239 | Service ports; each gRPC service's membership port is its port minus 300 (6933, 6936, …) |
| `[engine.tls]`, `[engine.auth]` | off | TLS and identity-provider tokens; see [engine security](engine-security.md) |
| `[engine.metrics]` `prometheusAddress` | off | `host:port` serving Prometheus metrics at `/metrics` |

Other tables (`[runtime]`, `[users]`, the portals) belong to other components and are ignored here.
Other tables (`[users]`, the portals) and other `[runtime]` keys belong to other components and are ignored here.

## Behavior

Expand Down Expand Up @@ -75,8 +86,7 @@ Other tables (`[runtime]`, `[users]`, the portals) belong to other components an

## Not covered yet

Authorization and TLS for the engine's own endpoints, profiles (which services a node runs), schema creation and
upgrade on first start, Cassandra, and secure-vault secrets.
Schema creation and upgrade on first start, Cassandra, and secure-vault secrets.

## Tests

Expand All @@ -86,5 +96,6 @@ upgrade on first start, Cassandra, and secure-vault secrets.
| `tools/internal/enginetest/sqlite_test.go` | A real engine on a new SQLite file creates the schema, keeps a namespace and a waiting workflow across a restart, and closes the workflow after it |
| `engine/internal/runtimeconfig/runtimeconfig_test.go` | What a redacted rendering cannot show: resolved environment passwords, redaction without changing the configuration, reading the file |
| `engine/internal/runtimeconfig/postgresqltls_test.go` | Temporal's PostgreSQL session verifies the certificate against the host, not `serverName`; it fails once Temporal passes the name through, so the rule can go |
| `engine/internal/cli/cli_test.go` | `start --runtime-config`, the authorizer check, one configuration only, `render-config` |
| `engine/internal/runtimeconfig/security_test.go` | Profiles, TLS, auth and metrics |
| `engine/internal/cli/cli_test.go` | `start --runtime-config`, the authorizer check, one configuration only, `render-config`, profiles and the claim mapper |
| `tests/ballerina/smoke` and `full`, with `--database sqlite\|postgresql\|mysql` | A real engine started from `runtime.toml` runs workflows on each database |
10 changes: 5 additions & 5 deletions docs/guides/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ housekeeping; integration workers never connect to it.

## Profiles

One distribution; each node runs the profiles it is given (launcher, planned).
One distribution; each node runs the profiles in its `runtime.toml` (`[runtime] profiles`).

| Profile | Starts |
|---|---|
| `all` (default) | Everything on one machine |
| `engine` | The four Temporal services and the engine endpoint |
| `frontend`, `history`, `matching`, `worker` | One Temporal service (`frontend` includes the engine endpoint) |
| `manager` | The Manager, with the portals it serves |
| `all` (default), `engine` | Every engine service |
| `frontend` | The frontend and the internal frontend (and the engine endpoint, when it exists) |
| `history`, `matching`, `worker` | One Temporal service |
| `api` | The API server, the Manager's planned name (the engine starts nothing for it) |

## Data

Expand Down
Loading
Loading