11 · Security & auth
Status: Implemented — auth + vault (T4, T5); users, API keys, audit, quotas, notifications (T17) · Owner: Platform
Authentication, roles, the credential vault, secrets handling, service-to-service auth, audit log, and network policy.
Authentication and roles
Section titled “Authentication and roles”- Every
/apiendpoint except/api/healthand login requires a principal. - Principals come from a JWT (HS256,
FLUX_SECRET_KEY, issuerflux.nasterra.com) sent asAuthorization: Bearer …(API clients) or theflux_sessionHttpOnly cookie (browser). - Roles, in increasing order: viewer (read), editor (create/change config, run pipelines), admin (users, keys, profiles, Forge trust, quotas).
- Routers declare the minimum role with
Depends(viewer | editor | admin)(flux_cp/auth/deps.py). 401 = no or invalid token, 403 = role too low. - Service principals (
kind: service) are used by Rust services calling back into the control plane (flux-dataset fetching the revocation list).
Users and sessions
Section titled “Users and sessions”Accounts are rows in users (flux_cp/accounts/), managed by admins under Admin.
| Passwords | argon2id (argon2-cffi defaults, rehashed on sign-in when parameters change), 12–500 characters |
| First admin | Before any user exists, FLUX_FIRST_ADMIN_EMAIL / FLUX_FIRST_ADMIN_PASSWORD signs in and becomes a real admin account. After that the variables are ignored |
| Invites | An admin enters an email and role; Flux emails a single-use link (7 days) to choose a password. Without mail configured, the link is shown to the admin to pass on |
| Resets | “Forgot your password?” emails a single-use link (60 minutes, at most one per minute per account). The answer is the same whether or not the address has an account |
| Link tokens | 32 random bytes; only their SHA-256 is stored |
| Lockout | 5 wrong passwords lock the account for 15 minutes, plus 10 failures per client address per 15 minutes |
| Sessions | 12 h JWT with the user’s ver (token version). Changing the password, the role or disabling the account bumps ver, so every existing session stops working on the next request |
| Guards | Admins can’t disable themselves, and the last active admin can’t be demoted or disabled |
API keys
Section titled “API keys”For applications and scripts (datasets, external events, the API).
- Created under Your account by editors and admins: name, role (at most the creator’s own), optional list of datasets, expiry (1–730 days, default 365).
- A key is a signed token (
kind: api_key,jti= key id,datasets), shown once. Flux stores only the key’s id and settings, so a leaked database doesn’t leak keys. - Every use checks the row: revoked, expired, or the owner disabled or now below the
key’s role all refuse it.
last_used_atis updated at most once a minute. - Dataset scopes: a key with
datasetssees only those through flux-dataset, in every endpoint and in SQL (other tables don’t exist for it). - Owners and admins revoke keys; admins see all keys. At most
api_keys_per_useractive keys per user.
flux-dataset verifies tokens locally (no call per request) and enforces revocation
from a list it fetches from GET /api/auth/revocations (service token): active users with
their current ver and role, and refused key ids. It refreshes every 15 s and right away
on flux.system.auth.changed, which the API publishes on user and key changes. If the
list is more than 5 minutes old, API keys are refused (fail closed); sessions fall back
to their 12 h expiry.
Credential vault
Section titled “Credential vault”Connection secrets are encrypted field-by-field inside the connection’s config body
(flux_cp/connections/vault.py).
| Property | Choice |
|---|---|
| Cipher | AES-256-GCM (authenticated), random 96-bit nonce per value |
| Stored form | {"$secret": "<key-id>:<b64 nonce>:<b64 ciphertext+tag>"} |
| Associated data | flux:connection:<type>:<field>: a ciphertext can’t be moved to another field or type |
| Key source | FLUX_VAULT_KEY from the flux-config k8s secret, never in git |
| Rotation | FLUX_VAULT_KEY=new:<b64>,old:<b64>. New writes use the first key; older keys still decrypt. Re-save connections to re-encrypt, then drop the old key |
| Dev key guard | The built-in development key is refused when FLUX_ENVIRONMENT=production |
Secrets never leave the server in plaintext.
- API responses replace each secret with
{"configured": true|false}. Diffs run on redacted bodies, so they show “changed/unchanged” and never the value. - Clients send plaintext only when setting a secret. Omitting a secret keeps the previous
encrypted value;
""clears it. Clients can’t submit ciphertext. connections.resolve()decrypts in memory for flux-preview and flux-runner requests. Resolved connections are passed to Rust services over the cluster network only. They are never logged or stored, and they never go into event payloads.- Rust services keep resolved credentials in memory for one request or run, pass them to the connector process over its private socket, and zero them after use where the driver allows.
Network
Section titled “Network”- Only flux-site, flux-web and flux-api are routed publicly. flux-preview, flux-dataset, flux-forge, object storage and NATS are ClusterIP only, with NetworkPolicies limiting who can reach them.
- The HTTP connector blocks private, loopback and link-local addresses by default
(
allow_private_networks: false) to prevent requests into the cluster (SSRF). - SFTP connections must pin the server host-key fingerprint.
audit_log is append-only: a database trigger refuses UPDATE and DELETE. Each entry
records when, who (and whether a user, API key or service), the action, the target
(kind + key), a detail object (secrets are never included) and the client address and
user agent. Admins browse it under Admin → Audit log (GET /api/audit, filters by
action prefix, actor, target, time).
| Action | When |
|---|---|
auth.login, auth.login_failed |
Sign-in attempts |
user.invite, user.update, user.invite_link, user.reset_link |
Admin user changes |
password.set, password.change, password.reset_requested |
Password changes |
api_key.create, api_key.revoke |
Keys |
config.create, config.save, config.activate, config.rollback, config.delete, config.update_meta |
Every versioned config change (pipelines, connections, schedules, quotas, …), written by the config service in the same transaction |
run.start, run.cancel |
Manual runs (scheduled and triggered runs are in firings) |
forge.revoke |
Artifact revocations |
dataset.writes, dataset.flush |
flux-dataset write policy changes and manual flushes, sent as flux.audit events and stored by the API’s indexer |
Entries are written in the same transaction as the change, so neither exists without the other.
Quotas
Section titled “Quotas”Platform limits are the versioned config item quotas/global (admin-only, with history and
rollback). Unset limits use the defaults.
| Limit | Default | Effect |
|---|---|---|
max_concurrent_cpu |
32 | Queued runs wait while running runs use this many CPUs (cpu × shards). FIFO: a large run at the head isn’t overtaken |
max_cpu_per_run |
32 | Larger runs are refused when queued |
runs_per_pipeline_per_day |
500 | New runs of a pipeline are refused after this many in 24 h (stops runaway triggers) |
api_keys_per_user |
20 | Active keys per user |
emails_per_hour |
200 | Notification emails beyond it are skipped; stays under the mail key’s 300/hour |
GET /api/quotas shows limits, defaults and current usage.
Notifications
Section titled “Notifications”Pipelines declare notifications (design 01): on any of succeeded, warning (a
success with warnings), failed, cancelled, send an email or call a webhook.
- When a run reaches its final status, one outbox row per matching notification is
written in the same transaction (
notifications), so nothing is lost and nothing is sent for a status that didn’t commit. A background loop in the API delivers them. - Email goes through the Nasterra mail service (template
flux-run-status, branded for nasterra.com; sources indeploy/mail-templates/): pipeline, outcome, run, start, duration, rows written, error, warnings and a link to the run. At most 20 recipients. - Webhooks must be
httpsand resolve to public addresses (no redirects, 10 s timeout). The body is{"type": "flux.run.notification", "delivery", "run": {…}}, signed withX-Flux-Signature: sha256=<hex HMAC-SHA256 of the body>usingFLUX_WEBHOOK_SECRET;X-Flux-Eventisrun.<outcome>. - Failed deliveries retry after 30 s, 2 min, 10 min, 30 min and 2 h, then stay
failedwith the error (GET /api/notifications). Without mail configured, emails areskipped. - Activation checks recipients and URLs.
Secrets in production
Section titled “Secrets in production”The API refuses to start with FLUX_ENVIRONMENT=production if FLUX_SECRET_KEY or
FLUX_WEBHOOK_SECRET is a development default or shorter than 32 characters; the vault
refuses the development vault key. The mail key (FLUX_MAIL_API_KEY) and all of these
come from the flux-config secret.
Open questions
Section titled “Open questions”- SSO (OIDC against the Nasterra identity provider) once one exists.
- Envelope encryption with an external KMS when moving to AWS (KMS data keys wrapping the vault key).