Credentials
Sources, streams, sinks and queues read a password, or any other property, with SECRET(provider, name [, key]). The registry stores the reference, never the value. featuremeshd, or the Python process that runs the engine, reads the value when it connects.
| Call | Reads |
|---|---|
SECRET('env', 'PG_PASSWORD') | the environment variable PG_PASSWORD of the process that connects |
SECRET('file', '/run/secrets/pg_password') | a file's content, without its trailing newline: Docker and Kubernetes secrets |
SECRET('file', '/run/secrets/db.json', 'password') | the field password of a file holding a JSON object, the shape secret managers often mount |
A database source's username and password properties replace the DSN's own user and password, encoded for the DSN, so a password may hold any character:
POSTGRES_CONN := SOURCE_DB(
'postgresql://db.internal:5432/shop?sslmode=require'
WITH (
username = SECRET('file', '/run/secrets/db.json', 'username'),
password = SECRET('file', '/run/secrets/db.json', 'password'),
tables = ARRAY('orders')
)
)
An HTTP source puts its token in headers ( Authenticated calls ). A stream takes PASSWORD and SSL_KEY_PASSWORD ( Connections ). A sink or a queue takes PASSWORD ( Properties ).
A rotated secret applies only once featuremeshd reads it again, at a time that depends on the kind ( Rotate credentials and certificates ).
An unreadable secret
A secret the engine cannot read fails its own definition, not the recompile. Here the environment variable is not set:
CREATE OR REPLACE FEATURE FM.TUTORIALS.EXTERNAL_JDBC.UNSET_SECRET_CONN AS
SOURCE_DB(
'postgresql://featuremesh@host.docker.internal:25432/featuremesh?sslmode=disable'
WITH (
password = SECRET('env', 'FEATUREMESH_DOCS_UNSET_PASSWORD'),
tables=ARRAY['serving_slt_customers']
)
);| feature_name VARCHAR | status VARCHAR | message VARCHAR |
|---|---|---|
| FM.TUTORIALS.EXTERNAL_JDBC.UNSET_SECRET_CONN | CREATED | Feature created as not exists |
RECOMPILE SERVING;| FEATURE VARCHAR | KIND VARCHAR | STATUS VARCHAR | MESSAGE VARCHAR | SINCE VARCHAR |
|---|---|---|---|---|
| FM.TUTORIALS.EXTERNAL_JDBC.POSTGRES_CONN | SOURCE_DB | LOADED | ||
| FM.TUTORIALS.EXTERNAL_JDBC.UNSET_SECRET_CONN | SOURCE_DB | ERROR | datasource: config parse failed: SECRET('env', 'FEATUREMESH_DOCS_UNSET_PASSWORD'): the environment variable is not set |
The source is in ERROR and nothing is served from it. The message names the secret, never a value, and the other sources are not affected. A stream, a sink or a queue loads, and its hook is STALLED until the secret can be read ( A missing secret, by kind ). How to fix it is in Deploy .
SECRET() is read only in the properties of a source, a stream or a sink, where the engine resolves it. A query that reads it elsewhere is refused, so a secret never ends up in a result:
RETURN
pg_password := SECRET('env', 'FEATUREMESH_DEMOS_PG_PASSWORD')
;No password in clear
A password written in clear, in a DSN, a URL, password, PASSWORD or SSL_KEY_PASSWORD, is stored by the registry and shown with the definition. The hosted platform refuses it with SOURCE-INLINE-PASSWORD. A local registry and the Python library store it with a warning.
CREATE OR REPLACE FEATURE FM.TUTORIALS.HOOK_REF.BAD AS SINK('postgresql://fm:s3cret@postgres:5432/fm' TABLE 'per_minute' KEY (merchant_id) WITH (MODE = 'latest'));Obvious placeholders pass with a warning, so prototypes and tests stay easy:
- an empty value, or only
x,*or.; - a value starting with
fake_,test_,dummy_orexample_; - a
<...>placeholder, or an${VAR}reference; - one of
password,secret,changeme,test,example,dummy,fake,demo,postgres,admin,featuremesh,local.