Secrets management

What is secrets management?

A secret is any sensitive piece of information required for API gateway operations.

Secrets can be information like the following:

  • TLS certificates
  • Credentials and API keys (to access databases, identity providers, and other services)
  • Cryptographic keys (for digital signing and encryption)

By storing these values as secrets, you ensure that they aren’t visible in plain text in logs, the UI, kong.conf, or decK files. Once a secret is stored, you can use the secret reference instead of the sensitive information. For example, a secret stored in an environment variable called MY_SECRET_POSTGRES_PASSWORD would be referenced with {vault://env/my-secret-postgres-password}.

You can reference secrets in the following Kong Gateway configuration:

  • Any field in the kong.conf
  • Referenceable fields in Kong plugins
  • Configuration associated with APIs serviced by Kong Gateway

How can I manage secrets in Kong Gateway?

Secret management options vary depending on which Kong Gateway tier you have. Kong Gateway OSS users can only manage secrets by storing them in environment variables. Kong Gateway Enterprise users can use environment variables as well as Vaults. The Vaults entity allows you to store and reference secrets from an external, third-party vault or Konnect Config Store.

Environment variables

Store secrets as environment variables and reference them in any field that supports Vault references.

Konnect Config Store

Use Konnect as a Vault backend using a Config Store.

Azure Key Vaults

Connect your Azure Key Vaults to Kong Gateway to reference secrets.

HashiCorp Vault

Connect HashiCorp Vault to Kong Gateway to reference secrets.

AWS Secrets Manager

Connect your AWS Secrets Manager to Kong Gateway to reference secrets.

Google Cloud Platform Secret Manager

Connect Google Cloud Platform Secret Manager to Kong Gateway to reference secrets.

CyberArk Conjur v3.11+

Connect CyberArk Conjur to Kong Gateway to reference secrets.

Secrets rotation

Secret rotation is a process that periodically updates secrets. Secret rotation is important for the following reasons:

  • Reducing the impact of compromised secrets
  • Enhancing resilience against brute-force attacks
  • Complying with security regulations
  • Maintaining separation of duties
  • Adapting to evolving threats
  • Mitigating the effects of insider threats

How can I rotate secrets in Kong Gateway?

If you have secrets rotation configured in your third-party vault settings, Kong Gateway can retrieve rotated secrets on a schedule. Kong Gateway can be configured to check for rotated secrets in the following ways:

  • Check periodically using TTLs (for example, check for new TLS certificates once per day). This can be configured in the Vault entity configuration.
  • Check on failure (for example, on database authentication failure, check if the secrets were updated, and try again). You must write code in Kong Gateway to configure this, so support is limited to PostgreSQL credentials for now.

Frequently Asked Questions

Did this doc help?

Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!