Upstream Authentication & TLS
The API Gateway adds the upstream credential to each call itself, so agents and users never see it. Configure it in the Upstream card of the API's edit page.
Auth Types
| Auth type | Settings | Secret field | Sent to the upstream as |
|---|---|---|---|
| None | — | — | No credential |
| Bearer token | — | Bearer token | Authorization: Bearer <token> |
| API key | Key name, send in Header or Query parameter | API key | X-API-Key: <key> (or your header name), or ?api_key=<key> |
| Basic | Username | Password | Authorization: Basic <base64(username:password)> |
| OAuth2 client credentials | Token URL, client ID, optional scope and audience | Client secret | Authorization: Bearer <access token> |
WS-Security (ws_security) | Username, password type, timestamp lifetime | Password | A <wsse:Security> UsernameToken header inside the SOAP envelope — see WS-Security |
OAuth2 client credentials
The gateway requests an access token from your Token URL with grant_type=client_credentials, your client ID and secret (plus scope and audience if set), and uses it as a bearer token.
- Tokens are cached and reused until 60 seconds before they expire (using
expires_in, or 5 minutes if the token endpoint doesn't say), so the token endpoint isn't called on every request. - The Token URL passes the same network protections and host allow-list as the upstream.
- Changing the client ID, scope, audience or secret invalidates the cached token.
- If the token endpoint fails, calls return
502 upstream_auth_failed.
WS-Security
For SOAP services that require an OASIS WS-Security UsernameToken. The credential travels inside the SOAP envelope, not in an HTTP header, so every operation needs a SOAP request protocol mapper. A call to an operation without one is refused with 502 upstream_auth_unsupported.
Set it on the API with auth_type: "ws_security", the password as auth_key, and these auth_config settings:
auth_config key | Default | Notes |
|---|---|---|
wsse_username | — (required) | The UsernameToken username |
wsse_password_type | text | text sends the password (#PasswordText). digest sends Base64(SHA-1(nonce + created + password)) with a fresh nonce instead of the password (#PasswordDigest) |
wsse_timestamp_ttl | 300 | Seconds until the wsu:Timestamp expires, 0–86400. 0 sends no Timestamp |
wsse_must_understand | true | Marks the header soap:mustUnderstand |
A new header is built for every request, with the SOAP version of the operation's mapper, and it is never cached or logged. When you import a WSDL whose policy asks for a UsernameToken, the proposal's suggested_auth is ws_security. WS-Security is set through the API only for now; the Upstream card doesn't list it yet.
Secrets are never returned
The secret field (token, API key, password or client secret) is encrypted at rest and always shown as •••••••• after saving. Leave it unchanged to keep the current secret, or type a new value to replace it.
Custom CA and Mutual TLS
Tick Custom CA or mutual TLS on the Upstream card for upstreams that use a private certificate authority or require a client certificate:
| Field | Use |
|---|---|
| CA certificate (PEM) | Trust an upstream whose server certificate is signed by your own CA |
| Client certificate (PEM) | The certificate the gateway presents for mutual TLS |
| Client private key (PEM) | The matching private key — stored encrypted, shown as •••••••• after saving |
Certificates are checked when you save, and an invalid PEM is rejected. The same TLS settings are used for the OAuth2 token request. TLS settings that can't be loaded at call time return 502 upstream_tls_config_invalid.
Secret Rotation
The Security card lets you view and rotate secrets without pulling the API back to draft or re-approving it. These actions are available to lifecycle_manager, space_admin and admin, and each is recorded in the API's audit log.
| Action | What it does | Effect |
|---|---|---|
| Show gateway secret | Displays the gateway URL, the gateway secret and a ready-to-run curl example, so the API can be called from outside Hrida.ai | Nothing changes. Each view is audited (REVEAL_GATEWAY_SECRET). If the API has never been published, a secret is generated |
| Rotate gateway secret | Replaces the secret between callers and the gateway, and shows the new one | The old secret stops working at once, on every server, when they share Redis; the Tool Server entry is updated, so agents pick up the new one automatically. Update any external caller with the new value |
| Rotate upstream credential | Replaces the upstream secret and/or the TLS client private key | The next call uses the new credential; nothing else about the API changes |
The same actions are available in the API:
POST /api/v1/api-definitions/{id}/gateway-secret/reveal
→ {"gateway_secret": "...", "gateway_url": "https://.../api/v1/api-definitions/{id}/proxy", "require_caller_identity": false}
POST /api/v1/api-definitions/{id}/rotate-gateway-secret (response includes "gateway_secret" once)
POST /api/v1/api-definitions/{id}/rotate-upstream-credential {"auth_key": "...", "tls_client_key": "...", "notes": "quarterly rotation"}
Rotating the encryption key
Every stored secret (upstream credentials, gateway secrets, TLS client keys, stage credentials, catalog and trigger secrets) is encrypted with one key ring:
| Variable | What it is |
|---|---|
HRIDAAI_ENCRYPTION_KEY | The current key. When unset, HRIDAAI_SECRET_KEY is used |
HRIDAAI_ENCRYPTION_KEYS_PREVIOUS | Older keys, comma-separated, still accepted for reading |
To change the key:
-
Set the new key as
HRIDAAI_ENCRYPTION_KEY, and the old one (if you never set one: yourHRIDAAI_SECRET_KEY) inHRIDAAI_ENCRYPTION_KEYS_PREVIOUS, on Studio and the gateway service. Restart them. -
Re-encrypt every stored secret with the new key:
bashdocker exec <studio container> python -m hrida_ai_studio.models.catalog_secrets rotateIt prints how many secrets it re-encrypted, and how many no key could read (those are left as they are).
-
Remove the old key from
HRIDAAI_ENCRYPTION_KEYS_PREVIOUSand restart.
With HRIDAAI_ENCRYPTION_KEY set, HRIDAAI_SECRET_KEY, which signs sessions, can also change without touching stored secrets.
If an API's upstream credential can't be decrypted with any key in the ring (for example after the key changed without step 1), its calls fail with 502 upstream_credentials_unreadable and the server log says so, rather than the upstream being called with an empty credential. Add the old key back, or enter the credential again with Rotate upstream credential.
Send Authorization: Bearer <gateway secret> to <gateway URL>/<operation path>, for example curl -H "Authorization: Bearer $SECRET" https://hrida.example.com/api/v1/api-definitions/<id>/proxy/posts/1. Only published APIs are served, and the call is refused if the API's policy has Require a signed caller identity turned on, since only Hrida.ai agents can sign one.
Related
- API Gateway — where the credential is applied in the pipeline
- Gateway Policy & Security — network protections and the host allow-list
- API Catalogs, Spaces & Roles — who can rotate secrets