Skip to main content
Keep the master key, the bootstrap token, and the tenant API key in a .env file, out of the configuration file and your shell history. Every pgw command reads the .env file in the folder where you run it, except pgw init, pgw version, and pgw with an unknown command. The file is optional. pgw init writes a .env file with mode 600 that holds a new PGW_MASTER_KEY and PGW_BOOTSTRAP_TOKEN. pgw bootstrap adds the new tenant’s PGW_API_KEY to the file when the file exists. Keep the file out of version control.

Format

pgw reads only lines whose name starts with PGW_ and skips every other line unparsed, so you can share the file with another tool.

Which source wins

pgw takes each setting from the first source that has it:
  1. A non-empty variable in the shell’s environment. An empty variable counts as unset.
  2. The .env file.
  3. The configuration file, for settings that have a YAML key.
  4. The default.
When a shell variable replaces a different value in .env, pgw writes pgw: warning: your shell overrides <NAME> from .env to stderr, once per name, without the value. PGW_MASTER_KEY and PGW_MASTER_KEY_FILE are one setting. When the shell sets either, pgw ignores both in .env.

Protect the file

Except on Windows, pgw serve refuses to start when the .env file holds the PGW_MASTER_KEY that pgw uses, and the file’s group or other users can access the file. The check also applies when the shell sets the same key. It doesn’t apply when the shell sets PGW_MASTER_KEY_FILE or a different key. Restrict the mode:
When pgw bootstrap saves the API key to a .env file that others can read, it first makes the file readable by you only, and prints a warning.

Next steps

Settings reference

Look up the environment variable, default, and range of each setting.

Security

Protect the master key, and limit who can reach the admin API.