Variables de seguretat
Tokens, xifratge, hosts REST de sortida, emmascarament i els antics ajustos VAULT_*
Canvia aquestes variables per definir els teus propis secrets de token i de xifratge, i per limitar què poden cridar i mostrar els formularis.
Exemple
Els teus propis secrets, crides REST limitades a una API i a una xarxa interna, i una clau emmascarada més. Al .env del projecte 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
Defineix ENCRYPTION_SECRET abans de desar la primera credencial. Des de la 7.3.0, definir-la o canviar-la torna a xifrar tots els secrets desats a la següent arrencada, amb ENCRYPTION_SECRET_PREVIOUS indicant la clau antiga quan era teva, vegeu Canviar el secret de xifratge.
Crides REST i jq
Des de la 7.3.0 les funcions auxiliars REST (fn.fnRestBasic, fn.fnRestAdvanced, fn.fnRestJwt, fn.fnRestJwtSecure) comproven el certificat de l’endpoint que criden, com qualsevol altra connexió; fins a la 7.2.0 no ho feien mai. S’hi apliquen tres ajustos:
| Variable | Predeterminat | Efecte |
|---|---|---|
REST_IGNORE_CERTS | 0 | 1 omet la comprovació del certificat: només per a endpoints amb un certificat autosignat |
REST_TIMEOUT_SECONDS | 60 | Quant espera una crida REST una resposta abans de fallar per temps d’espera esgotat |
JQ_TIMEOUT_SECONDS | 30 | Quant pot funcionar un filtre jq abans que s’aturi; la sortida de jq també està limitada a 64 MB |
Totes tres tenen efecte en desar-les, sense reiniciar. Per a un endpoint el certificat del qual està signat per una CA privada, mantén la comprovació activada i dona aquesta CA a Node.js: defineix NODE_EXTRA_CA_CERTS amb un fitxer PEM que la contingui a l’entorn de l’aplicació i reinicia l’aplicació.
Variables
Totes les variables d’aquest grup, amb el seu tipus, el seu valor predeterminat i la seva descripció:
| Variable | Opcions/Valors per defecte | Comentaris |
|---|---|---|
| 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 Secret | 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 per defecte: 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 per defecte: 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 per defecte: 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 per defecte: 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 per defecte: 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 per defecte: 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 per defecte: https://login.microsoftonline.com | Microsoft Entra ID sign-in authority (deprecated)
Deprecated: use |
| AZURE_GRAPH_URI string added in version 4.0.3 | Valor per defecte: https://graph.microsoft.com | Azure Graph API base URI (deprecated)
Deprecated: use |
| REST_ALLOWED_HOSTS string added in version 6.0.0 | Valor per defecte: | 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 per defecte: | 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 per defecte: 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 per defecte: 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 per defecte: 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 | Opcions:
| 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 per defecte: 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 | Valor per defecte: 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 per defecte: 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 per defecte: 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 per defecte: 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 per defecte: 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 per defecte: 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 Secret | Valor per defecte: *** 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 per defecte: 30m | Access token expiration
A JWT (Json Web Token) is only valid for a certain amount of time. |
| ACCESS_TOKEN_REFRESH_EXPIRATION string | Valor per defecte: 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 per defecte: ansibleforms | Access token issuer
The issuer of the access token is the name of the application that issues the token. |
| ENCRYPTION_SECRET string Secret | Valor per defecte: *** 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 Secret added in version 7.3.0 | Valor per defecte: | 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 per defecte: \[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 per defecte: 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 per defecte: | 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 |