Authentication
By default, the Coflux engine requires authentication. There are several authentication methods available, which can be used independently or combined.
Disabling authentication
For local development, authentication can be disabled by starting the engine with the --no-auth flag:
coflux engine --no-auth
This allows anonymous access to all endpoints. This is not recommended for production use.
Super token
A super token provides full access to the engine. It is configured when starting the engine:
coflux engine --super-token "my-secret-token"
The token can then be used with the CLI:
coflux submit --token "my-secret-token" mymodule/my_workflow
Or in coflux.toml:
token = "my-secret-token"
If configuring the engine via environment variables or a configuration file, you can provide the SHA-256 hash of the token instead of the plaintext token using COFLUX_SUPER_TOKEN_HASH. This is recommended for production environments where the token shouldn't appear in configuration files.
Service tokens
Service tokens can be created and scoped to specific workspaces, making them suitable for CI/CD pipelines, production workers, or as an alternative to Studio authentication for individual users:
coflux tokens create --name "CI" --workspaces "production/*"
A pattern selects workspaces: production is that workspace alone, production/* is the workspaces under it, and * is all of them. Give several, comma-separated, for the union — production,production/* covers a workspace and everything under it. The * spans any depth, so production/* reaches production/eu/batch, and it follows the / in names, so neither pattern ever selects production-2.
A token can't be created with broader access than the token creating it has: each pattern it asks for has to sit wholly inside one the creator holds. A token created without --workspaces inherits the creating token's access.
Service tokens require COFLUX_SECRET to be configured on the engine. This secret is used to derive per-project signing keys.
To manage tokens:
coflux tokens list
coflux tokens revoke <token-id>
Studio authentication
Members of a team in Studio can authenticate through it, rather than holding a token for the engine. Log in with the device authorization flow, approving it in the browser:
coflux login
This stores a device token for this machine, in ~/.config/coflux/credentials.json. The device token is only ever sent to Studio. Whenever the CLI needs to reach an engine, it exchanges the device token for a project token, which lasts an hour and is only good for that engine's host, and gets another when it's needed. So there's nothing long-lived for an engine to be given.
A login lasts for 90 days, or until it's gone unused for 30. After that, coflux login again.
A project token is for you as a member of a team. If just one of your teams has a project at the engine's host, Studio works out which, and nothing more is needed. (The CLI only asks Studio about an engine that has refused it for want of a token.) Otherwise, say which team, with --team, COFLUX_TEAM, or in coflux.toml:
host = "coflux.example.com"
team = "team-id-1"
The engine, in turn, needs to be told which teams to accept, with COFLUX_STUDIO_TEAMS:
coflux engine --team team-id-1 --team team-id-2
To log out:
coflux logout
This removes the stored login, and has Studio revoke the device token, so that it's no use to anyone else. A device can also be revoked from your settings in Studio.
A login is kept for each Studio, so logging in to another (set with COFLUX_STUDIO_URL) leaves the first as it is. coflux logout --all removes them all.
Worker authentication
A worker uses the configured token (from coflux.toml, the --token flag, or Studio login) to register its modules and start a session with the engine. From then on it uses its session's own token, for its connection to the engine and for sending blobs, logs and metrics. A session's token only reaches the workspace the worker is in.