Secret References and Secrets Files
A secret value is never part of a metadata file. The file holds a named reference, and the value lives in a secrets file, in the credential store on the machine, or, except on a hosted instance of BimlFlex, in an environment variable of the process that runs the build.
The secret reference
A sensitive property, such as the password of a connection, holds an object with a $secret property in place of the value. The $secret property holds a token of the form provider:path.
"password": { "$secret": "store:AWLT-password" }
A literal value in a sensitive property is an error (BFXF007). A save that puts a literal value in a sensitive property is refused and writes no metadata file. A secret value written to its secrets file ahead of that save stays written.
Providers
A build resolves two providers. A build on a hosted instance of BimlFlex resolves only store: tokens, and an env: token does not resolve there.
| Token | Resolves from |
|---|---|
env:<variable> | The environment variable of that name in the process that runs the build. The whole value of the variable is the secret. A build on a hosted instance does not read it. |
store:<name> | The secrets files of the store first, and the BimlFlex credential store on the machine second. |
Secrets files
The secrets files of a store live in its .bimlflex folder. Each secrets file is one JSON object. Every member is keyed by the full token, such as store:AWLT-password, and holds the secret as text in double quotes, or null for a secret that is not filled in yet.
| File | Holds |
|---|---|
secrets.json | The default secrets file, with filled values. |
secrets.template.json | A blank template that can be shared. |
secrets.<environment>.json | The values for one environment. A store has one such file per environment. |
Environment names
An environment name is 1 to 64 letters, digits, dashes or underscores. The word template is reserved in any letter case. BimlFlex refuses a name that differs from an existing secrets file only by letter case.
Resolution order
For a store: token, the first of these sources that holds the name answers:
- The secrets file of the environment in effect, when that file exists.
- The default secrets file, when it exists.
- The credential store.
With no environment in effect, the only secrets file read is the default file.
The environment in effect is the environment the BimlFlex App names for the action. When it names none, it is the current environment set for the store folder, which is never committed. When neither is set, no environment is in effect.
The secrets environment in the toolbar
In file mode, the toolbar of the BimlFlex App shows the secrets environment. Its menu offers Default, the known environments, and a field for a new environment name.
Revealing and writing a value
The BimlFlex App can reveal one secret value on demand for the environment in effect, and it can write a value to a secrets file. The metadata file keeps the token in both cases.
Secrets during migration
For how secrets are handled when a BimlFlex database moves to files, see Migrate a BimlFlex database to files.
See File Store Diagnostic Codes for BFXF007, ERR_BAD_SECRET_TOKEN, ERR_RAW_SECRET_IN_FILE_MODE and SECRETS_FILE_MALFORMED.