Variables de seguridad
Tokens, cifrado, hosts REST salientes, enmascaramiento y los antiguos ajustes VAULT_*
Cambia estas variables para definir tus propios secretos de token y de cifrado, y para limitar lo que los formularios pueden llamar y mostrar.
Ejemplo
Tus propios secretos, llamadas REST limitadas a una API y a una red interna, y una clave enmascarada más. En el .env del proyecto compose:
ACCESS_TOKEN_SECRET=change-me-to-a-long-random-string
ENCRYPTION_SECRET=change-me-to-32-random-characters
REST_ALLOWED_HOSTS=api.example.com,10.20.0.0/16
MASK_EXTRAVARS_REGEX=password|secret|token|apikey
Define ENCRYPTION_SECRET antes de guardar la primera credencial. Desde la 7.3.0, definirla o cambiarla vuelve a cifrar todos los secretos guardados en el siguiente arranque, con ENCRYPTION_SECRET_PREVIOUS indicando la clave antigua cuando era tuya, consulta Cambiar el secreto de cifrado.
Llamadas REST y jq
Desde la 7.3.0 las funciones auxiliares REST (fn.fnRestBasic, fn.fnRestAdvanced, fn.fnRestJwt, fn.fnRestJwtSecure) comprueban el certificado del endpoint al que llaman, como cualquier otra conexión; hasta la 7.2.0 no lo hacían nunca. Se les aplican tres ajustes:
| Variable | Predeterminado | Efecto |
|---|---|---|
REST_IGNORE_CERTS | 0 | 1 omite la comprobación del certificado: solo para endpoints con un certificado autofirmado |
REST_TIMEOUT_SECONDS | 60 | Cuánto espera una llamada REST una respuesta antes de fallar por tiempo de espera |
JQ_TIMEOUT_SECONDS | 30 | Cuánto puede ejecutarse un filtro jq antes de detenerse; la salida de jq también está limitada a 64 MB |
Las tres se aplican al guardarlas, sin reiniciar. Para un endpoint cuyo certificado está firmado por una CA privada, mantén la comprobación activada y dale esa CA a Node.js: define NODE_EXTRA_CA_CERTS con un archivo PEM que la contenga en el entorno de la aplicación y reinicia la aplicación.
Variables
Todas las variables de este grupo, con su tipo, su valor predeterminado y su descripción:
| Variable | Opciones/Valores predeterminados | Comentarios |
|---|---|---|
| VAULT_ADDR string | HashiCorp Vault address (deprecated)
Deprecated since 7, removed in 8. The first 7.x start that finds these variables imports them once as the secret store | |
| VAULT_TOKEN string Secreto | HashiCorp Vault token (deprecated)
Deprecated since 7, removed in 8. The first 7.x start that finds these variables imports them once as the secret store | |
| VAULT_NAMESPACE string | HashiCorp Vault namespace (deprecated)
Deprecated since 7, removed in 8. The first 7.x start that finds these variables imports them once as the secret store | |
| VAULT_KV_VERSION number | Valor predeterminado: 2 | Vault KV secret engine version (deprecated)
Deprecated since 7, removed in 8. The first 7.x start that finds these variables imports them once as the secret store |
| VAULT_DEFAULT_MOUNT string | Valor predeterminado: secret | Default Vault KV mount (deprecated)
Deprecated since 7, removed in 8. The first 7.x start that finds these variables imports them once as the secret store |
| VAULT_CACHE_TTL_MS number | Valor predeterminado: 60000 | Vault read cache TTL (ms) (deprecated)
Deprecated since 7, removed in 8. The first 7.x start that finds these variables imports them once as the secret store |
| VAULT_SKIP_VERIFY string | Valor predeterminado: false | Skip Vault TLS verification (deprecated)
Deprecated since 7, removed in 8. The first 7.x start that finds these variables imports them once as the secret store |
| ENTRA_AUTHORITY_URI string added in version 7.3.0 | Valor predeterminado: https://login.microsoftonline.com | Microsoft Entra ID sign-in authority
The Microsoft identity platform the server sends a Microsoft Entra ID sign-in to, with the tenant id of the provider after it ( |
| ENTRA_GRAPH_URI string added in version 7.3.0 | Valor predeterminado: https://graph.microsoft.com | Microsoft Graph API base URI
The Microsoft Graph endpoint the server calls at a Microsoft Entra ID login to read the user’s group membership ( |
| AZURE_AUTHORITY_URI string added in version 7.0.4 | Valor predeterminado: https://login.microsoftonline.com | Microsoft Entra ID sign-in authority (deprecated)
Deprecated: use |
| AZURE_GRAPH_URI string added in version 4.0.3 | Valor predeterminado: https://graph.microsoft.com | Azure Graph API base URI (deprecated)
Deprecated: use |
| REST_ALLOWED_HOSTS string added in version 6.0.0 | Valor predeterminado: | Allowed hosts for REST expressions
Comma-separated list of hostnames and/or CIDR ranges that REST helper functions ( When set, only these destinations are allowed; everything else is blocked. When unset, no allow-list is applied (default behaviour, all hosts allowed). Hostnames are matched case-insensitively against the URL host; CIDRs are matched against the IPs that the host resolves to (so an entry like Example: Caveat: this only protects the AnsibleForms Node.js process. Ansible playbooks run on the host directly and bypass this guard. |
| REST_DENIED_HOSTS string added in version 6.0.0 | Valor predeterminado: | Blocked hosts for REST expressions
Comma-separated list of hostnames and/or CIDR ranges that REST helper functions ( Wins over Hostnames are matched case-insensitively against the URL host; CIDRs are matched against the IPs that the host resolves to. Caveat: this only protects the AnsibleForms Node.js process. Ansible playbooks run on the host directly and bypass this guard. |
| REST_TIMEOUT_SECONDS number added in version 7.3.0 | Valor predeterminado: 60 | REST call timeout (seconds)
How long the REST helper functions ( Without a limit, an endpoint that never answers kept the request and the form field waiting forever. A value that is not a number above 0 falls back to the default. Takes effect when saved. |
| REST_IGNORE_CERTS boolean added in version 7.3.0 | Valor predeterminado: 0 | Ignore REST certificates
Whether the REST helper functions ( Until 7.3.0 they never checked it, so a man in the middle could read their tokens and answers. They now check it like every other connection: trust a private CA with NODE_EXTRA_CA_CERTS, or set this to 1 only for endpoints with a self-signed certificate. Takes effect when saved. |
| JQ_TIMEOUT_SECONDS number added in version 7.3.0 | Valor predeterminado: 30 | jq timeout (seconds)
How long a jq filter may run before the jq process is killed: A runaway filter (for example a recursive definition that never ends) used to keep a jq process spinning forever. jq output is also capped at 64 MB. A value that is not a number above 0 falls back to the default. Takes effect when saved. |
| EXPRESSION_SANITIZER string added in version 6.3.0 | Opciones:
| Server expression sanitizer
Server expressions (fields of type
An unknown value falls back to |
| API_TOKEN_MAX_DAYS number added in version 7.0.0 | Valor predeterminado: 90 | API token maximum life (days)
A role with the Profile > API token makes one for any account. A local or LDAP user confirms their password ; a Microsoft Entra ID or OIDC user has none here, so the token is made from their session, which must have signed in at most 10 minutes before (the page sends them through the sign-in again otherwise). An API token cannot make another. Each token is listed on the profile and on the user’s page in Settings > Users (made, expires, last used), where the user or an admin revokes it. Blocking a user ends their tokens too. An SSO user’s token carries the roles of their last sign-in: a group change in the identity provider reaches it only when they sign in again and make a new one. |
| PASSWORD_MIN_LENGTH number added in version 7.0.0 | Valor predeterminado: 8 | Minimum password length
A local password set through the application - a new user, an admin setting it, a user changing their own - needs at least this many characters, and is neither the username nor the public default password. Length rather than composition rules: a long passphrase is strong and easy to remember. ADMIN_PASSWORD at the first start is not checked. Applied without a restart. |
| CONTENT_SECURITY_POLICY number added in version 7.0.0 | Valor predeterminado: 1 | Enforce the Content-Security-Policy
The web app is served with a Content-Security-Policy: scripts from the app itself only, so a script injected into a page does not run, and no other site may frame it. It allows what the app needs: local form expressions (evaluated in the browser), inline styles, images from any url (form and category images), and the code editor’s workers. With 0 it is sent as Content-Security-Policy-Report-Only: the browser’s console says what it would block, and nothing is blocked - for a setup that cannot work with it yet, a reverse proxy that injects its own script for example. |
| AUTH_RATE_LIMIT number added in version 7.0.0 | Valor predeterminado: 120 | Sign-in requests a minute from one address
A ceiling on the authentication endpoints - the login, the logout, the token refresh and the single sign-on callbacks - per client address and per app node: above it they answer 429 before any password or token is looked at. Generous, so that a person or a script never reaches it ; LOGIN_MAX_FAILURES is what stops a password from being guessed. Behind a reverse proxy, set TRUST_PROXY so the address is the client’s. Applied without a restart. |
| LOGIN_MAX_FAILURES number added in version 7.0.0 | Valor predeterminado: 5 | Failed sign-ins before an account locks
After this many failed logins in a row, an account (local or LDAP) is locked for LOGIN_LOCKOUT_MINUTES: every attempt is refused with status 429 before any password is checked, whether the account exists or not. A successful login clears the count, and so does an admin setting the user’s password. Counted in the database, so every app node sees the same attempts. 0 turns the lockout off. Applied without a restart. |
| LOGIN_MAX_FAILURES_PER_IP number added in version 7.0.0 | Valor predeterminado: 30 | Failed sign-ins from one address before it is held back
One address trying many accounts: after this many failed logins within LOGIN_LOCKOUT_MINUTES, every login from it is refused with status 429 until that window ends. Behind a reverse proxy, set TRUST_PROXY so the address is the client’s and not the proxy’s. 0 turns it off. Applied without a restart. |
| LOGIN_LOCKOUT_MINUTES number added in version 7.0.0 | Valor predeterminado: 15 | Account lockout (minutes)
How long an account stays locked after LOGIN_MAX_FAILURES failed logins, and the window in which the failures of an account and of an address are counted. 0 turns the lockout and the per-address limit off. Applied without a restart. |
| ACCESS_TOKEN_SECRET string Secreto | Valor predeterminado: *** NOT REVEALED *** | Access token secret
AnsibleForm uses Basic Authentication as authentication mechanism. Not set: each start generates a random secret, so a restart ends every session and everyone logs in again. An app node ( |
| ACCESS_TOKEN_EXPIRATION string | Valor predeterminado: 30m | Access token expiration
A JWT (Json Web Token) is only valid for a certain amount of time. |
| ACCESS_TOKEN_REFRESH_EXPIRATION string | Valor predeterminado: 24h | Refresh token expiration
Once the access token is expired, and the client tries to connect to the server, the client hits a 401 error (unauthorized). The client application captures this error, and calls the refresh API with its refresh token. If the refresh token is valid, the client gets a new set of access and refresh tokens and retries the last unauthorized api call with the renew access token. |
| ACCESS_TOKEN_ISSUER string added in version 5.0.8 | Valor predeterminado: ansibleforms | Access token issuer
The issuer of the access token is the name of the application that issues the token. |
| ENCRYPTION_SECRET string Secreto | Valor predeterminado: *** NOT REVEALED *** | Encryption secret
AnsibleForms encrypts the passwords and tokens it stores in the database with this secret. Set your own : without it they are encrypted with a default key that is public in the source code. The secret must be 32 characters long ; a shorter one is extended and a longer one cut. Setting it, or changing it, re-encrypts every stored secret with it on the next start, in one transaction, so none is lost : from the default key the first time, from ENCRYPTION_SECRET_PREVIOUS after that. Set the same value on every app node, the worker and every RTE that registers itself. |
| ENCRYPTION_SECRET_PREVIOUS string Secreto added in version 7.3.0 | Valor predeterminado: | Previous encryption secret
When ENCRYPTION_SECRET changes from a key of your own to another, set this to the old one for one start : every stored secret is re-encrypted from it to the new ENCRYPTION_SECRET, then it is not used and can be removed. Not needed when ENCRYPTION_SECRET is set for the first time (the stored secrets are then re-encrypted from the default key). When the stored secrets were encrypted with a key that is neither, nothing is changed and the worker refuses to start, saying in the log which variable to set. |
| REGEX_FILTER_JOB_OUTPUT string | Valor predeterminado: \[low\] | Job output filter (regex)
Sometime, the job output is flooded with meaningless output, such as ‘Gathering Facts’, or ‘Includes’. You filter out these by add a piece of string in the taskname, i.e. |
| MASK_EXTRAVARS_REGEX string | Valor predeterminado: password|secret|token | Extravars to mask (regex)
When you have sensitive extravars, such as passwords, tokens, keys, credentials, you do not want these to be shown in clear text in the extravars section of a job. Since 6.4.1 the value of every |
| EXTRAVARS_USER_FIELDS string | Valor predeterminado: | User fields in the extravars
Every job carries the launching user as Leave it empty (the default) and the whole object is sent, exactly as in every release before this one. Set it to a comma separated list of top level keys, for example A single form can override this with its Note: the FAQ suggests asserting on |