Sources and signers
A src reference in a workspace or template is resolved by the provider named by its prefix: file:, https:, cloudfront: or a SIGN_* key. The same signers are available from /api/sign/<signer>; the cloudfront and s3 signers answer 405 when not configured. Key files are read relative to XYZ_CWD.
SRC_*
SRC_<NAME> replaces ${NAME} in every src reference the API resolves, including WORKSPACE and CUSTOM_TEMPLATES. A placeholder without a variable is left unchanged.
SRC_ASSETS=assets.example.com/maps{ "src": "https://${ASSETS}/templates/layer.json" }file: paths and cloudfront: URLs also replace {NAME} in single braces, eg. file:{RESOURCES}/layer.json. There a missing variable gives the text undefined.
Values are substituted in src references and in the URLs of locale.plugins and layer.plugins, which getLocale and getLayer pass through the same envReplace; not elsewhere in a workspace. DIR is not an SRC_* variable, so a ${DIR} in a plugin URL stays unless SRC_DIR is set.
SIGN_*
SIGN_<KEY> connects another XYZ instance as a source. The value is its host, with an optional path and without a scheme; https:// is prepended. The private key is read at startup from <KEY>.pem; an unreadable file is logged.
SIGN_ASSETS=assets.example.com/geoA src ASSETS:templates/layer.json is then fetched from https://assets.example.com/geo/api/provider/file with the path, an expiry one day ahead, the key id and an HMAC-SHA256 signature made with the key. The other instance must hold the same key to verify the signature; that check is not part of apps/xyz. A value with https:// gives a doubled scheme.
FILE_RESOURCES, default resources, is the directory under XYZ_CWD from which files are served to signed file provider requests.
CloudFront
KEY_CLOUDFRONT is the CloudFront key pair id. The private key is read from <KEY_CLOUDFRONT>.pem when the module loads. It enables the cloudfront: src provider and the cloudfront signer, and needs the optional @aws-sdk/cloudfront-signer dependency. Signed URLs expire at the next midnight, server time. {NAME} placeholders in the URL are replaced from SRC_*.
S3
AWS_S3_CLIENT holds the access key id and secret as URL search params, and enables the s3 signer. It needs the optional @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner dependencies.
AWS_S3_CLIENT=accessKeyId=<access-key-id>&secretAccessKey=<secret-access-key>The request names an S3 client command, eg. GetObjectCommand, with Bucket, Key and Region. The signed URL is valid for one hour. Public buckets can be read without the signer.
Cloudinary
CLOUDINARY_URL is the Cloudinary environment variable, cloudinary://<api_key>:<api_secret>@<cloud_name>. It enables the cloudinary signer, which returns a signed upload URL for a folder and public_id, or a destroy URL with destroy=true.
CUSTOM_TEMPLATES
CUSTOM_TEMPLATES is a src for a JSON object of templates by key, eg. file:/templates/custom.json. It is loaded each time the workspace cache is built. Its templates replace the core view, mail, message and query templates of the same key, and workspace templates replace both. A source which fails to load is recorded as a workspace error; the workspace still loads with the core templates.
Keep the keys and secrets of all signers in a secret manager or the varlock schema.