Secret manager connections from the Admin UI
A secret manager connection is normally set with environment variables before the gateway starts. Config overrides let a proxy admin set or change that connection while the gateway runs, from the Admin Settings page or with the /config_overrides routes. The gateway logs in to the secret manager with the new values before it stores anything, keeps the stored values encrypted with the salt key, redacts every secret it sends back, and writes each change to the audit log. The stored connection wins over the deployment's environment variables on every instance that reads it, and GET shows you which values are in force. Config overrides exist for HashiCorp Vault and CyberArk Conjur.
A real-world scenario
The security team rotates the AppRole secret id the gateway uses to log in to Vault every quarter. Instead of redeploying the gateway with a new HCP_VAULT_APPROLE_SECRET_ID, the platform admin opens Admin Settings, chooses the Hashicorp Vault tab, presses Edit Configuration, pastes the new secret id and saves. The gateway logs in to Vault with it, stores it encrypted, and the models that read their keys from Vault keep working. Afterwards the admin presses Test Connection to see the confirmation and checks the audit log, where the change is recorded with the secret redacted.
How a stored connection and environment variables combine
Every field you leave out of a save keeps its stored value, or the value of the matching environment variable when nothing is stored yet, so you can change one field at a time. Sending an empty string clears a field. The field names match the environment variables one to one.
| Vault field | Environment variable | Conjur field | Environment variable |
|---|---|---|---|
vault_addr | HCP_VAULT_ADDR | cyberark_api_base | CYBERARK_API_BASE |
vault_token | HCP_VAULT_TOKEN | cyberark_account | CYBERARK_ACCOUNT |
approle_role_id, approle_secret_id, approle_mount_path | HCP_VAULT_APPROLE_ROLE_ID, HCP_VAULT_APPROLE_SECRET_ID, HCP_VAULT_APPROLE_MOUNT_PATH | cyberark_username | CYBERARK_USERNAME |
client_cert, client_key, vault_cert_role | HCP_VAULT_CLIENT_CERT, HCP_VAULT_CLIENT_KEY, HCP_VAULT_CERT_ROLE | cyberark_api_key | CYBERARK_API_KEY |
vault_namespace, vault_login_namespace, vault_secret_namespace | HCP_VAULT_NAMESPACE, HCP_VAULT_LOGIN_NAMESPACE, HCP_VAULT_SECRET_NAMESPACE | client_cert, client_key | CYBERARK_CLIENT_CERT, CYBERARK_CLIENT_KEY |
vault_mount_name, vault_path_prefix | HCP_VAULT_MOUNT_NAME, HCP_VAULT_PATH_PREFIX | ssl_verify, refresh_interval | CYBERARK_SSL_VERIFY, CYBERARK_REFRESH_INTERVAL |
A Vault save needs vault_addr and one way to log in, a token, both AppRole fields, or both certificate fields. A Conjur save needs cyberark_api_base and either cyberark_api_key or both certificate fields. Always send cyberark_account and cyberark_username too, because without them Conjur is called with the account default and the login admin, which is rarely what you want. The gateway logs in with the merged values before it stores them, so a wrong secret is refused at once and the previous connection stays in place. The token, AppRole secret id, API key and client key are masked in every answer and redacted in the audit log. When more than one Vault login method is stored, AppRole wins over the certificate and the certificate over the token, so clear the old method's fields when you switch.
The stored connection needs DATABASE_URL. It is applied on the instance that received the save at once. Other instances pick it up when they next reload their config, and a fresh instance loads it at startup, but only when general_settings.store_model_in_db is true and supported_db_objects, when set, includes config_overrides. Without those, other instances keep their environment variables.
Save the connection
-
In the Admin UI open Settings, then Admin Settings, and choose the Hashicorp Vault or CyberArk Conjur tab. A tab with nothing stored and no environment variables shows Configure Vault or the matching CyberArk button, a configured one shows the stored fields with Auth Method worked out from them.
-
Press Configure Vault or Edit Configuration, fill in the address and one authentication method, and press Save. The secret fields show Leave blank to keep existing, so an empty secret field keeps the stored secret. The same save over the API is:
curl -X POST http://localhost:4000/config_overrides/hashicorp_vault \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"vault_addr": "https://vault.example.com:8200","approle_role_id": "6b1c0d4e-8b32-4a2a-9d4e-1f7a2c3b4d5e","approle_secret_id": "s.9f8e7d6c5b4a3f2e1d0c","vault_mount_name": "secret","vault_path_prefix": "spanway"}'For Conjur, post to
/config_overrides/cyberarkwithcyberark_api_base,cyberark_account,cyberark_usernameandcyberark_api_key.Expected result:
{"message": "Hashicorp Vault configuration updated successfully", "status": "success"} -
Press Test Connection. The gateway logs in again and looks the token up, or for Conjur calls its whoami route, and shows the address it reached. Over the API the test takes no body:
curl -X POST http://localhost:4000/config_overrides/hashicorp_vault/test_connection \-H "Authorization: Bearer $SPANWAY_API_KEY"Expected result:
{"status": "success", "message": "Successfully connected to Vault at https://vault.example.com:8200"} -
Read the connection back to see which values are in force. Secrets come back masked, and
field_schemais what the Admin UI form is built from.curl http://localhost:4000/config_overrides/hashicorp_vault -H "Authorization: Bearer $SPANWAY_API_KEY"Expected result:
{"config_type": "hashicorp_vault","values": {"vault_addr": "https://vault.example.com:8200","approle_role_id": "6b1c0d4e-8b32-4a2a-9d4e-1f7a2c3b4d5e","approle_secret_id": "s.9f********","vault_mount_name": "secret","vault_path_prefix": "spanway"},"field_schema": {"vault_addr": {"type": "string", "description": "The address of the Vault server"}}} -
Open Logs, then Audit logs, and filter on the
hashicorp_vaultorcyberarkobject to see thecreatedorupdatedrow. The row keeps the plain fields such as the address, mount, namespaces, account and username in its before and after values, so you can see what changed, and shows***REDACTED***for the token, AppRole secret id, API key and client key. Test Connection writes no row. Rows are written whenstore_audit_logsis on, see audit logs.
Clear one field or remove the connection
On the tab, the trash button next to a stored field opens Clear followed by the field name, and Delete in that dialog sends a save with that field set to an empty string. Delete Configuration opens a confirmation that warns that models using the secret manager lose their keys until a new connection is saved, and Delete removes the stored connection.
curl -X DELETE http://localhost:4000/config_overrides/cyberark -H "Authorization: Bearer $SPANWAY_API_KEY"
Expected result:
{"message": "CyberArk configuration deleted successfully", "status": "success"}
Deleting the Vault connection also clears its HCP_VAULT_* variables on the instance and unloads the secret manager. Deleting the Conjur connection puts the deployment's own CYBERARK_* variables back in force when there were any, and unloads the secret manager otherwise. Deleting with nothing stored also answers 200.
Routes
| Method | Path | Summary |
|---|---|---|
| GET | /config_overrides/cyberark | Read the CyberArk Conjur connection |
| POST | /config_overrides/cyberark | Save the CyberArk Conjur connection |
| DELETE | /config_overrides/cyberark | Remove the CyberArk Conjur connection |
| POST | /config_overrides/cyberark/test_connection | Test the CyberArk Conjur connection |
| GET | /config_overrides/hashicorp_vault | Read the HashiCorp Vault connection |
| POST | /config_overrides/hashicorp_vault | Save the HashiCorp Vault connection |
| DELETE | /config_overrides/hashicorp_vault | Remove the HashiCorp Vault connection |
| POST | /config_overrides/hashicorp_vault/test_connection | Test the HashiCorp Vault connection |
Proxy admins can save, test and delete. Admin viewers can read the masked values. Every other role gets a 403.
Errors
| Status | Route | Meaning | Fix |
|---|---|---|---|
400 Vault Address is required or CyberArk API Base is required | POST /config_overrides/... | The merged values have no server address. | Send the address, or set the environment variable on the deployment. |
400 At least one authentication method is required | POST /config_overrides/... | No token, no complete AppRole pair and no complete certificate pair. | Send one method completely, both AppRole fields or both certificate fields. |
400 Hashicorp Vault is not configured. Save a configuration first. or the CyberArk equivalent | POST .../test_connection | No connection is loaded on this instance. | Save a connection, or restart an instance that only has environment variables. |
403 Only admin users can update config overrides | POST /config_overrides/hashicorp_vault, POST /config_overrides/cyberark | The key is not a proxy admin key. | Use a proxy admin key. |
403 Only admin users can view config overrides | GET /config_overrides/... | The key is neither a proxy admin nor an admin viewer key. | Use a proxy admin or admin viewer key. |
403 Only admin users can delete config overrides | DELETE /config_overrides/... | The key is not a proxy admin key. | Use a proxy admin key. |
403 Only admin users can test Vault connection or Only admin users can test CyberArk connection | POST .../test_connection | The key is not a proxy admin key. | Use a proxy admin key. |
500 Failed to initialize secret manager: ... | POST /config_overrides/... | The secret manager refused the login with the merged values. Nothing was stored and the previous values are back in force. | Check the address, the credentials and the network path from the gateway, then save again. |
500 Failed to persist Hashicorp Vault configuration: ... or Failed to persist CyberArk configuration: ... | POST /config_overrides/... | The login worked but the database write failed. The previous connection is back in force and nothing was stored. | Check the database, then save again. |
500 No connected database | all routes | The gateway runs without DATABASE_URL. | Connect a database, or set the connection with environment variables. |
502 Vault authentication failed or Vault token validation failed, and the CyberArk equivalents | POST .../test_connection | The stored connection no longer works, for example the secret id was rotated on the secret manager side. | Save the new credential and test again. |
Logs
| Level | Line | Meaning |
|---|---|---|
| ERROR | Error reinitializing Hashicorp Vault secret manager: ... or Error reinitializing CyberArk secret manager: ... | A save was refused because the store did not accept the merged values. The previous environment is restored and the 500 answer carries the detail. |
| ERROR | Error persisting Hashicorp Vault configuration: ... or Error persisting CyberArk configuration: ... | The database write of a save failed. The previous connection is restored. |
| DEBUG | Hashicorp Vault config override loaded from DB or CyberArk config override loaded from DB | An instance loaded the stored connection at startup or on a config reload. Normal. |
| ERROR | Error loading Hashicorp Vault config override from DB: ... or Error loading CyberArk config override from DB: ... | An instance could not decrypt or apply the stored connection, usually because its SPANWAY_SALT_KEY differs from the one the save used. The instance keeps its previous connection. Give every instance the same salt key. |
Related
- Secret managers for
hosted_keys, access modes and the other shared settings. - HashiCorp Vault for the secret layout and the policy the role needs.
- CyberArk Conjur for the variable layout and the host policy.
- Admin Settings page for every control on the two tabs.
- Audit logs for the rows these routes write.
- Production checklist for the salt key the stored values are encrypted with.