Skip to content

Bring Your Own Key Store: Keep Integration Secrets in Your AWS Account

Truto's key store (BYOK) writes your connected accounts' OAuth tokens and API keys into your own AWS Secrets Manager, encrypted with your KMS key. Truto keeps only a reference, and loses access the moment you revoke it.

Sidharth Verma Sidharth Verma · · 10 min read
Bring Your Own Key Store: Keep Integration Secrets in Your AWS Account

Truto now lets each environment keep its integration secrets in your own AWS Secrets Manager, encrypted with your own KMS key. When a key store is in use, the OAuth tokens, API keys and OAuth app overrides behind your customers' connected accounts are written to your AWS account. Truto keeps only a reference to each secret. It reads the value when a request needs it, and it loses access the moment you deactivate the access key you gave it.

This post explains why we built it, what moves into your store and what does not, how Truto reads and writes secrets at runtime, and how to set it up. The full reference is in the key store guide.

Why a key store

A unified API holds a lot of trust. Every connected account is a live credential into a customer's CRM, HRIS, ticketing or accounting system. Most B2B SaaS teams are fine with an integration vendor encrypting those credentials at rest. A growing number are not, and the reason is usually one of three:

  1. Security reviews ask who can read the tokens. An enterprise buyer's security team wants to know who holds the keys to their Salesforce or Workday tenant. "Our vendor encrypts them" is a weaker answer than "they sit in our AWS account, under our KMS key, and we can cut access in one click."
  2. Compliance wants the key under your control. Regulated teams often require customer-managed keys for any third-party credential they handle. With a key store, the KMS key policy, CloudTrail logs and key rotation belong to you.
  3. Revocation should not depend on the vendor. If you ever need to stop a vendor from using your customers' credentials, you want a switch you own. Deactivating one IAM access key is that switch.

If you have read our guide to secure, GDPR-ready unified APIs, a key store is the credential half of the same idea: keep the sensitive material on infrastructure you control.

What goes into your store, and what stays in Truto

A key store belongs to one environment. Once it is in use, these secrets go to it:

  • Connected account credentials. Everything in the account's context: OAuth access and refresh tokens, API keys, passwords and any other values the integration stores there.
  • Connected account overrides. For example, an account that uses its own OAuth app credentials.
  • Environment integration overrides. For example, your own OAuth app's client ID and client secret for an integration.

Each secret gets a predictable name under your prefix (truto/ by default):

Secret Name in Secrets Manager
Account credentials truto/<environment_id>/<integrated_account_id>
Account overrides truto/<environment_id>/<integrated_account_id>/integration-override
Integration overrides truto/<environment_id>/environment-integration/<environment_integration_id>

Some things stay in Truto. OAuth apps that Truto provides are Truto's credentials, so they stay with Truto. Non-secret metadata (account ID, tenant, integration, status) stays in Truto too, because Truto needs it to route requests. In place of the secret, the account row holds an opaque reference that names the key store, the secret and the exact AWS version to read.

Info

Encryption happens on the AWS side. Truto writes each secret with Secrets Manager's CreateSecret and PutSecretValue, and passes your KMS key when you set one. If you name no key, Secrets Manager uses its AWS-managed key. Truto makes no direct KMS calls and never holds your KMS key material.

How Truto uses your store at runtime

Here is what happens when a unified API or proxy request needs a connected account's token:

sequenceDiagram
    participant App as Your app
    participant Truto
    participant SM as Your AWS Secrets Manager
    participant KMS as Your KMS key
    participant API as Third-party API

    App->>Truto: GET /unified/crm/contacts?integrated_account_id=...
    Truto->>Truto: Load account row (holds a reference, not the token)
    alt Value cached (≤ 5 min)
        Truto->>Truto: Use cached value
    else Not cached
        Truto->>SM: GetSecretValue (exact VersionId)
        SM->>KMS: Decrypt
        KMS-->>SM: Plaintext data key
        SM-->>Truto: Secret value
    end
    Truto->>API: Request with the account's token
    API-->>Truto: Response
    Truto-->>App: Unified response

The rules behind that flow are deliberately strict:

  • Reads are on demand and cached briefly. Truto reads a secret when a request needs it and keeps the value in memory for up to 5 minutes. The 5-minute limit also bounds how long a revoked store keeps working.
  • There is no fallback. If your store is unreachable or AWS refuses access, a request that needs the secret fails with HTTP 503 and truto_error_code: key_store_unavailable. Truto never serves a copy of its own for a secret that lives in your store.
  • Calls fail fast under trouble. Each AWS call times out after 3 seconds and is tried up to 3 times. After 5 failed calls in a row, Truto stops calling that store for 30 seconds, so a struggling AWS region does not pile up slow requests.
  • Token refreshes are spaced out. Secrets Manager keeps at most 100 versions of a secret. Truto therefore writes a given secret at most once every 15 minutes. If an integration refreshes tokens faster than that, Truto keeps the newest token encrypted on its side until the next write lands. Integrations with longer-lived tokens never wait.
  • Credential endpoints still work. Endpoints that return credentials to callers allowed to see them still return them. The values come from your store.
  • Deletes are recoverable. Deleting an account or integration deletes its secret with a 7-day recovery window. Deletes run in the background and are best effort. If AWS refuses, Truto logs it and the secret stays under your prefix for you to clean up.

If you are building OAuth token management yourself, these are the same trade-offs you would face. The key store makes them for you and keeps the token in your account.

Setting up a key store

Only team admins can manage key stores, from Settings → Key store in the Truto dashboard. The setup takes four steps.

1. Create an IAM user for Truto

In the AWS account that will hold the secrets, create an IAM user and an access key for it. Attach no policy yet. Truto has no AWS identity of its own here: this access key is the only way Truto reaches your store. That design is what makes revocation simple.

2. Connect the key store

Pick the environment and click Connect key store. The form asks for:

Field Required Notes
Name Yes A label, for example Production AWS
AWS region Yes For example us-east-1. Cannot change later
Secret name prefix No Default truto/. Cannot change later
KMS key No Key ARN (recommended), key ID, alias name or alias ARN
Access key ID Yes From step 1
Secret access key Yes Truto stores it encrypted and never returns it

When you click Connect, Truto checks the access key with sts:GetCallerIdentity, which needs no permissions, and records your AWS account ID. A rejected key is refused at once. The store starts as Connecting, and Truto writes nothing to it until you verify it.

3. Attach the generated policy

Open Set up access on the store. Truto generates an inline policy for the IAM user, scoped to your region, account, prefix and KMS key. For the prefix truto/ in us-east-1, it looks like this:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "TrutoKeyStoreSecrets",
      "Effect": "Allow",
      "Action": [
        "secretsmanager:CreateSecret",
        "secretsmanager:GetSecretValue",
        "secretsmanager:PutSecretValue",
        "secretsmanager:DeleteSecret",
        "secretsmanager:RestoreSecret"
      ],
      "Resource": "arn:aws:secretsmanager:us-east-1:123456789012:secret:truto/*"
    },
    {
      "Sid": "TrutoKeyStoreKms",
      "Effect": "Allow",
      "Action": ["kms:GenerateDataKey", "kms:Decrypt"],
      "Resource": "arn:aws:kms:us-east-1:123456789012:key/<key_id>",
      "Condition": {
        "StringEquals": {
          "kms:ViaService": "secretsmanager.us-east-1.amazonaws.com"
        }
      }
    }
  ]
}

Two details matter:

  • The policy reaches only secrets under your prefix. The IAM user cannot list, read or change anything else in Secrets Manager.
  • The kms:ViaService condition means the IAM user can use the KMS key only through Secrets Manager, never to decrypt arbitrary data directly.

Without a KMS key, the KMS statement is left out. If you use a customer managed KMS key, its key policy must also allow the IAM user to use it.

4. Verify

Click Verify. Truto runs a full round trip on a test secret under truto-verify/: write, read back, delete, restore, then delete permanently. That checks every permission Truto will need later. On success, the store becomes Active. If it is the environment's first store, it is also In use. On failure, the store shows Validation error with AWS's reason, so you can fix the policy and verify again.

Moving existing secrets without re-authentication

Turning on a key store does not break existing connections, and nobody has to reconnect.

Secrets written before the store was in use stay encrypted by Truto until they move. They move in one of two ways:

  • On their next change. A token refresh, a reconnect, or an edit to credentials or an override writes the new value to your store.
  • All at once. Click Move all now on the store in use. A background job moves connected accounts first, then integration overrides. The Secrets section shows how many secrets are in your store, still in Truto, or in another store.

Move all now is safe to click again. A secret is never moved twice, and a second run picks up anything the first run skipped. After a move lands, Truto holds only the reference.

Revoking access

To cut Truto off, deactivate or delete the IAM user's access key in AWS. Nothing in Truto needs to change.

  • Reads stop within 5 minutes. Values already in memory expire. After that, every request that needs a secret from your store fails with key_store_unavailable.
  • Writes stop at once. On a token refresh, Truto keeps the new token encrypted and retries the write. After about 20 retries, Truto gives up. The account moves to needs_reauth with a last_error that says the key store refused the credentials, the integrated_account:authentication_error webhook fires, and Truto drops its copy of the new token.

To restore access, reactivate the key, or save a new access key with Edit on the store.

Warning

Revocation is a real kill switch. Connected accounts in that environment stop working until access returns. Use it when you mean it, and watch the integrated_account:authentication_error webhook if accounts might reach needs_reauth.

Switching, disabling and deleting stores

An environment can have several key stores, but only one is In use at a time. That makes it possible to move to a new AWS account, region or prefix without downtime:

  1. Add the new store, attach its policy and verify it. It shows Not in use.
  2. Click Activate on the new store. Truto verifies it again, makes it the store in use and stops writes to the old one, in one step.
  3. Click Move all now on the new store. Until a secret moves, Truto still reads it from the old store.
  4. When the old store's Secrets section shows nothing left, delete it.

Region, prefix and AWS account are fixed per store, so changing any of them means a new store. The name, KMS key and access key can be edited in place. A new KMS key applies only to secrets created afterwards.

Disable stops new secrets from going to a store, but existing secrets stay there and are still read. Delete is allowed only for a store that is not in use, at least one minute after it stopped being in use, and only when no account or integration keeps a secret in it. Otherwise Truto refuses with 409 and says why. Truto also refuses to delete an environment or a team that still has a key store.

Managing key stores with the API

Everything in the dashboard is available through the key stores API:

Method Path What it does
GET /key-store-provider Supported providers and their fields
GET /key-store List key stores in your environments
POST /key-store Create a store (environment_id, name, provider, config, credentials)
GET /key-store/:id/setup The IAM policy to attach
POST /key-store/:id/verify Run the verification round trip
POST /key-store/:id/activate Make this store the one in use
GET /key-store/:id/usage Where secrets currently live
POST /key-store/:id/move-secrets Start the background move
PATCH /key-store/:id Change name, config or credentials, or disable with is_current: false
DELETE /key-store/:id Delete a store that is not in use and empty

Every change must come from a signed-in team admin. Truto refuses POST, PATCH and DELETE on key stores made with an API token, so a leaked token cannot point your secrets somewhere else.

What a key store does not change

To be precise about the boundary:

  • Truto still handles plaintext while it works. To call a third-party API, Truto needs the token. Values are cached in memory for up to 5 minutes. A token refresh that has not yet landed in your store is held encrypted on Truto's side until it does.
  • Truto-provided OAuth apps stay with Truto. If an integration uses Truto's own OAuth app, those app credentials are not yours to store.
  • Only AWS Secrets Manager is supported today, in the aws and aws-us-gov partitions. AWS China regions are not supported.

A key store moves where credentials live at rest and who controls access to them. It does not remove Truto from the request path. Combined with zero data retention for the data that flows through Truto, it gives you a strong answer to the question every enterprise security review asks: where do our customers' credentials live, and who can turn them off?

FAQ

What is BYOK in Truto?
BYOK in Truto is a bring-your-own key store. An environment connects to your AWS Secrets Manager, and Truto writes connected-account credentials and integration overrides there instead of storing them itself. Secrets Manager encrypts them with your KMS key, or the AWS-managed key if you name none. Truto keeps only a reference to each secret.
Which secrets go into my key store?
Three kinds: the credentials in each connected account's context (OAuth access and refresh tokens, API keys, passwords), overrides on a connected account such as its own OAuth app credentials, and overrides on an environment integration such as your own OAuth client ID and secret. OAuth apps that Truto provides, and non-secret metadata like account ID, tenant and status, stay in Truto.
Which key stores does Truto support?
AWS Secrets Manager, in the aws and aws-us-gov partitions. AWS China regions are not supported. Truto signs in with an access key of an IAM user that you create, and you attach a policy Truto generates that reaches only secrets under your chosen prefix.
What happens if I revoke Truto's access to my key store?
Deactivate or delete the IAM user's access key. Values Truto already read stay in memory for up to 5 minutes. After that, every request that needs a secret from your store fails with HTTP 503 and truto_error_code key_store_unavailable. Truto never falls back to a copy of its own.
Do I have to reconnect every account when I turn on a key store?
No. Existing secrets move on their next change, such as a token refresh or reconnect, or all at once when an admin clicks Move all now. The move runs in the background and no customer has to re-authorize.
Can I manage key stores with an API token?
No. Every change to a key store (POST, PATCH, DELETE) must come from a signed-in team admin. Truto refuses key store changes made with an API token. Reads such as listing stores or fetching the setup policy are available through the API.

More from our Blog