CyberArk Conjur
The CyberArk integration reads secrets from CyberArk Conjur. The gateway authenticates to Conjur as a host or user, obtains a short lived access token, refreshes it on an interval, and resolves os.environ/NAME references in the config from Conjur variables.
The CyberArk Conjur integration needs an Enterprise license. Without one the gateway refuses to start when key_management_system names it. AWS Secrets Manager, AWS KMS, Google Cloud KMS and Azure Key Vault work on Starter, see secret managers.
A real-world scenario
A company stores its machine credentials in CyberArk Conjur. The admin gives the gateway a Conjur host identity, stores the Anthropic key as a Conjur variable, and connects the gateway from the Admin UI, so the key is read at startup and never stored on the gateway host.
Steps
-
Create the variable in Conjur, give the gateway's host
readandexecuteon it, and set its value to the provider key. -
In the Admin UI open Settings, then Admin Settings, and select the CyberArk Conjur tab. Enter the API base, account, host identity and API key and save. The same with the API:
curl -X POST http://localhost:4000/config_overrides/cyberark \-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \-d '{"cyberark_api_base": "https://conjur.example.com", "cyberark_account": "myorg", "cyberark_username": "host/spanway-gateway", "cyberark_api_key": "<api key>"}' -
Test the connection.
curl -X POST http://localhost:4000/config_overrides/cyberark/test_connection -H "Authorization: Bearer $SPANWAY_MASTER_KEY" -
Add the variable name to
hosted_keysas in Configuration and send a request to a model that uses it.
Expected result
The test reports success, and the model answers with the key read from Conjur.
Configuration
general_settings:
key_management_system: cyberark
key_management_settings:
hosted_keys: ["OPENAI_API_KEY", "ANTHROPIC_API_KEY"]
| Variable | Default | Purpose |
|---|---|---|
CYBERARK_API_BASE | http://127.0.0.1:8080 | Conjur URL. |
CYBERARK_ACCOUNT | default | Conjur account name. |
CYBERARK_USERNAME | admin | Login of the host or user, for example host/spanway-gateway. |
CYBERARK_API_KEY | none | API key for the login. |
CYBERARK_CLIENT_CERT, CYBERARK_CLIENT_KEY | none | Client certificate and key for certificate authentication, instead of an API key. |
CYBERARK_SSL_VERIFY | true | Set to false to skip TLS verification in test environments. |
CYBERARK_REFRESH_INTERVAL | 300 | Seconds a Conjur login token and the secrets read with it are kept in memory. Conjur tokens expire after about eight minutes, so keep it below that. |
Either CYBERARK_API_KEY or both certificate variables must be set, otherwise the gateway refuses to start the secret manager with a message naming the missing credentials.
Secret layout
A reference os.environ/OPENAI_API_KEY reads the Conjur variable with that id. Create the variables and grant the gateway's host read access in your Conjur policy.
- !variable OPENAI_API_KEY
- !host spanway-gateway
- !permit
role: !host spanway-gateway
privileges: [read, execute]
resource: !variable OPENAI_API_KEY
export CYBERARK_API_BASE="https://conjur.example.com"
export CYBERARK_ACCOUNT="myorg"
export CYBERARK_USERNAME="host/spanway-gateway"
export CYBERARK_API_KEY="..."
docker run --rm -p 4000:4000 -v "$PWD/config.yaml:/app/config.yaml" \
-e SPANWAY_MASTER_KEY -e CYBERARK_API_BASE -e CYBERARK_ACCOUNT -e CYBERARK_USERNAME -e CYBERARK_API_KEY \
registry.spanway.ai/spanway/spanway-ai:2.0.0 --config /app/config.yaml
Writing virtual keys
With a write access mode and store_virtual_keys: true, new virtual keys are written as Conjur variables under the configured prefix. The gateway retries policy loads a few times when Conjur is briefly unavailable. Deleting a virtual key does not remove its Conjur variable, because Conjur has no delete call. The variable stays until a Conjur policy removes it, and the gateway logs a warning instead.
Troubleshooting
Authentication failures return 401 from Conjur and are logged without the API key. A 404 on a variable means the id or account is wrong or the host lacks read and execute on it. See secret managers for hosted_keys and the other shared settings.
Errors
| What you see | What it means | Fix |
|---|---|---|
The gateway fails to start with CyberArk secret manager is only available for premium users | No Enterprise license is set, and this store needs one. | Set SPANWAY_LICENSE to your license key and restart. |
The gateway fails to start with Missing CyberArk credentials. Please set CYBERARK_API_KEY or both CYBERARK_CLIENT_CERT and CYBERARK_CLIENT_KEY in your environment. | No login method is set. | Set the API key, or both certificate variables. |
Lookups fail with Could not authenticate to CyberArk Conjur: ... | Conjur refused the login. | Check CYBERARK_ACCOUNT, CYBERARK_USERNAME and the API key or certificate. |
Logs
| Level | Line | Meaning | Action |
|---|---|---|---|
| WARNING | CyberArk SSL verification is disabled. This is insecure and should only be used for testing with self-signed certificates. | CYBERARK_SSL_VERIFY is false. | Normal only in a lab. Turn verification back on in production. |
| ERROR | Error reading secret from CyberArk Conjur: ... | A read failed, for example with 401 or 404. | Check the variable id and the host's permissions. |
| ERROR | Error writing secret to CyberArk Conjur: ... | Writing a virtual key failed. | Check that the host may update variables under the prefix. |
| WARNING | CyberArk Conjur does not support direct secret deletion... | A virtual key was deleted, its variable stays in Conjur. | Remove it with a Conjur policy when needed. |
Related
- Secret managers.
- Admin Settings page for the CyberArk Conjur tab.
- Config overrides.