セキュリティの変数
トークン、暗号化、外部への REST ホスト、マスキング、古い VAULT_* 設定
独自のトークンと暗号化のシークレットを設定し、フォームが呼び出せるものと表示できるものを制限するには、これらを変更します。
例
独自のシークレットを使い、REST の呼び出しを一つの API と内部ネットワークに制限し、マスクするキーを一つ追加します。compose プロジェクトの .env では次のようにします。
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
ENCRYPTION_SECRET は、最初の認証情報を保存する前に設定してください。7.3.0 からは、設定または変更すると、次回の起動時に保存されている すべてのシークレットが再暗号化されます。古いキーが独自のものだった場合は ENCRYPTION_SECRET_PREVIOUS でそれを指定します。 暗号化シークレットの変更 を参照してください。
REST の呼び出しと jq
7.3.0 からは、REST のヘルパー関数( fn.fnRestBasic 、 fn.fnRestAdvanced 、 fn.fnRestJwt 、 fn.fnRestJwtSecure )は、ほかのすべての接続と同じく、 呼び出すエンドポイントの証明書を検証します。7.2.0 までは検証していませんでした。これらには三つの設定が適用されます。
| 変数 | 既定値 | 効果 |
|---|---|---|
REST_IGNORE_CERTS | 0 | 1 にすると証明書の検証を省略します。自己署名証明書を持つエンドポイント専用です |
REST_TIMEOUT_SECONDS | 60 | REST の呼び出しがタイムアウトで失敗するまでに応答を待つ時間 |
JQ_TIMEOUT_SECONDS | 30 | jq フィルターが停止されるまでに実行できる時間。jq の出力も 64 MB に制限されます |
三つとも、保存すると再起動なしで反映されます。プライベート CA が署名した証明書を持つエンドポイントでは、検証はオンのままにして、 代わりにその CA を Node.js に渡してください。アプリの環境で NODE_EXTRA_CA_CERTS にその CA を含む PEM ファイルを設定し、アプリを再起動します。
変数
このグループのすべての変数と、その型、既定値、説明:
| 変数 | 選択肢/既定値 | 説明 |
|---|---|---|
| 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 シークレット | 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 | 既定値: 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 | 既定値: 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 | 既定値: 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 | 既定値: 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 | 既定値: 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 | 既定値: 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 | 既定値: https://login.microsoftonline.com | Microsoft Entra ID sign-in authority (deprecated)
Deprecated: use |
| AZURE_GRAPH_URI string added in version 4.0.3 | 既定値: https://graph.microsoft.com | Azure Graph API base URI (deprecated)
Deprecated: use |
| REST_ALLOWED_HOSTS string added in version 6.0.0 | 既定値: | 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 | 既定値: | 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 | 既定値: 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 | 既定値: 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 | 既定値: 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 | 選択肢:
| 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 | 既定値: 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 | 既定値: 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 | 既定値: 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 | 既定値: 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 | 既定値: 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 | 既定値: 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 | 既定値: 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 シークレット | 既定値: *** 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 | 既定値: 30m | Access token expiration
A JWT (Json Web Token) is only valid for a certain amount of time. |
| ACCESS_TOKEN_REFRESH_EXPIRATION string | 既定値: 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 | 既定値: ansibleforms | Access token issuer
The issuer of the access token is the name of the application that issues the token. |
| ENCRYPTION_SECRET string シークレット | 既定値: *** 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 シークレット added in version 7.3.0 | 既定値: | 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 | 既定値: \[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 | 既定値: 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 | 既定値: | 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 |