Variáveis de segurança
Tokens, cifragem, hosts REST de saída, mascaramento e as antigas definições VAULT_*
Altere estas para definir os seus próprios segredos de token e de cifragem, e para limitar o que os formulários podem chamar e mostrar.
Exemplo
Os seus próprios segredos, chamadas REST limitadas a uma API e a uma rede interna, e mais uma chave mascarada. No .env do projeto 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
Defina ENCRYPTION_SECRET antes de guardar a primeira credencial. A partir da 7.3.0, defini-la ou alterá-la volta a cifrar todos os segredos guardados no arranque seguinte, com ENCRYPTION_SECRET_PREVIOUS a indicar a chave antiga quando era sua, consulte Alterar o segredo de cifragem.
Chamadas REST e jq
A partir da 7.3.0, as funções auxiliares REST (fn.fnRestBasic, fn.fnRestAdvanced, fn.fnRestJwt, fn.fnRestJwtSecure) verificam o certificado do endpoint que chamam, como qualquer outra ligação; até à 7.2.0 nunca o faziam. Aplicam-se-lhes três definições:
| Variável | Predefinição | Efeito |
|---|---|---|
REST_IGNORE_CERTS | 0 | 1 salta a verificação do certificado: só para endpoints com um certificado autoassinado |
REST_TIMEOUT_SECONDS | 60 | Quanto tempo uma chamada REST espera por uma resposta antes de falhar por tempo limite |
JQ_TIMEOUT_SECONDS | 30 | Quanto tempo um filtro jq pode correr antes de ser parado; a saída do jq também está limitada a 64 MB |
As três produzem efeito ao serem guardadas, sem reiniciar. Para um endpoint cujo certificado está assinado por uma CA privada, mantenha a verificação ligada e dê antes essa CA ao Node.js: defina NODE_EXTRA_CA_CERTS com um ficheiro PEM que a contenha no ambiente da aplicação, e depois reinicie a aplicação.
Variáveis
Todas as variáveis deste grupo, com o seu tipo, predefinição e descrição:
| Variável | Opções/Valores predefinidos | Comentários |
|---|---|---|
| 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 Segredo | 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 | Predefinição: 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 | Predefinição: 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 | Predefinição: 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 | Predefinição: 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 | Predefinição: 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 | Predefinição: 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 | Predefinição: https://login.microsoftonline.com | Microsoft Entra ID sign-in authority (deprecated)
Deprecated: use |
| AZURE_GRAPH_URI string added in version 4.0.3 | Predefinição: https://graph.microsoft.com | Azure Graph API base URI (deprecated)
Deprecated: use |
| REST_ALLOWED_HOSTS string added in version 6.0.0 | Predefinição: | 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 | Predefinição: | 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 | Predefinição: 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 | Predefinição: 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 | Predefinição: 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 | Opções:
| 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 | Predefinição: 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. A token follows the roles of its user as they are now, within 30 seconds: the roles in the config, a local user’s groups as an admin sets them, an LDAP or SSO user’s groups as their last sign-in recorded them (a group change in the directory or identity provider reaches the token when they sign in again). |
| PASSWORD_MIN_LENGTH number added in version 7.0.0 | Predefinição: 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 | Predefinição: 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 | Predefinição: 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 | Predefinição: 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 | Predefinição: 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 | Predefinição: 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 Segredo | Predefinição: *** 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 | Predefinição: 30m | Access token expiration
A JWT (Json Web Token) is only valid for a certain amount of time. |
| ACCESS_TOKEN_REFRESH_EXPIRATION string | Predefinição: 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 | Predefinição: ansibleforms | Access token issuer
The issuer of the access token is the name of the application that issues the token. |
| ENCRYPTION_SECRET string Segredo | Predefinição: *** 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 Segredo added in version 7.3.0 | Predefinição: | 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 | Predefinição: \[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 | Predefinição: 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 | Predefinição: | 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 |