• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Vault
  • Install
  • Tutorials
  • Documentation
  • API
  • Integrations
  • Try Cloud(opens in new tab)
  • Sign up
Vault Home

Documentation

Skip to main content
  • Documentation
  • What is Vault?
  • Use Cases

  • Browser Support
  • Installing Vault

    • Overview
    • Active Directory
    • AliCloud
    • AWS
    • Azure
    • Consul
    • Cubbyhole
      • Overview
      • Cassandra
      • Couchbase
      • Elasticsearch
      • HanaDB
      • IBM Db2
      • InfluxDB
      • MongoDB
      • MongoDB Atlas
      • MSSQL
      • MySQL/MariaDB
      • Oracle
      • PostgreSQL
      • Redis
      • Redis ElastiCache
      • Redshift
      • Snowflake
      • Custom
    • Google Cloud
    • Google Cloud KMS
    • KMIP
      ENTERPRISEENTERPRISE
    • Kubernetes
    • MongoDB Atlas
    • Nomad
    • LDAP
    • RabbitMQ
    • Terraform Cloud
    • TOTP
    • Venafi (Certificates)
  • Vault Integration Program
  • Vault Interoperability Matrix
  • Troubleshoot






  • Glossary


  • Resources

  • Tutorial Library
  • Certifications
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  1. Developer
  2. Vault
  3. Documentation
  4. Secrets Engines
  5. Databases
  6. Couchbase
  • Vault
  • v1.11.x
  • v1.10.x
  • v1.9.x
  • v1.8.x
  • v1.7.x
  • v1.6.x
  • v1.5.x
  • v1.4.x

»Couchbase Database Secrets Engine

Note: This engine can use external X.509 certificates as part of TLS or signature validation. Verifying signatures against X.509 certificates that use SHA-1 is deprecated and is no longer usable without a workaround starting in Vault 1.12. See the deprecation FAQ for more information.

Couchbase is one of the supported plugins for the database secrets engine. This plugin generates database credentials dynamically based on configured roles for the Couchbase database.

See the database secrets engine docs for more information about setting up the database secrets engine.

Capabilities

Plugin NameRoot Credential RotationDynamic RolesStatic RolesUsername Customization
couchbase-database-pluginYesYesYesYes (1.7+)

Setup

  1. Enable the database secrets engine if it is not already enabled:

    $ vault secrets enable database
    Success! Enabled the database secrets engine at: database/
    

    By default, the secrets engine will enable at the name of the engine. To enable the secrets engine at a different path, use the -path argument.

  2. Configure Vault with the proper plugin and connection configuration:

    $ vault write database/config/my-couchbase-database \
        plugin_name="couchbase-database-plugin" \
        hosts="couchbases://127.0.0.1" \
        tls=true \
        base64pem="${BASE64PEM}" \
        username="vaultuser" \
        password="vaultpass" \
        allowed_roles="my-*-role"
    

    Where ${BASE64PEM} is the server's root certificate authority in PEM format, encoded as a base64 string with no new lines.

    To connect to clusters prior to version 6.5.0, a bucket_name must also be configured:

    $ vault write database/config/my-couchbase-database \
        plugin_name="couchbase-database-plugin" \
        hosts="couchbases://127.0.0.1" \
        tls=true \
        base64pem="${BASE64PEM}" \
        username="vaultuser" \
        password="vaultpass" \
        allowed_roles="my-*-role" \
        bucket_name="travel-sample"
    
  3. You should consider rotating the admin password. Note that if you do, the new password will never be made available through Vault, so you should create a Vault-specific database admin user for this.

    vault write -force database/rotate-root/my-couchbase-database
    

Usage

After the secrets engine is configured, configure dynamic and static roles to enable generating credentials.

Dynamic roles

  1. Configure a dynamic role that maps a name in Vault to a JSON string specifying a Couchbase RBAC role. The default value for creation_statements is a read-only admin role: {"Roles": [{"role":"ro_admin"}]}.

    $ vault write database/roles/my-dynamic-role \
        db_name="my-couchbase-database" \
        creation_statements='{"Roles": [{"role":"ro_admin"}]}' \
        default_ttl="5m" \
        max_ttl="1h"
    

    Note that any groups specified in the creation statement must already exist.

  2. Generate a new credential by reading from the /creds endpoint with the name of the role:

    $ vault read database/creds/my-dynamic-role
    Key                Value
    ---                -----
    lease_id           database/creds/my-dynamic-role/wiLNQjtcvCOT1VnN3qnUJnBz
    lease_duration     5m
    lease_renewable    true
    password           mhyM-Gs7IpmOPnSqXEDe
    username           v-root-my-dynamic-role-eXnVr4gm55dpM1EVgTYz-1596815027
    

Static roles

  1. Configure a static role that maps a name in Vault to an existing couchbase user.

    $ vault write database/static-roles/my-static-role \
        db_name="my-couchbase-database" \
        username="my-existing-couchbase-user" \
        rotation_period=5m
    
  2. Retrieve the credentials from the /static-creds endpoint:

    $ vault read database/static-creds/my-static-role
    Key                    Value
    ---                    -----
    last_vault_rotation    2020-08-07T16:50:48.393354+01:00
    password               Z4-KH8F-VK5VJc0hSkXQ
    rotation_period        5m
    ttl                    4m39s
    username               my-existing-couchbase-user
    

API

The full list of configurable options can be seen in the Couchbase database plugin API page.

For more information on the database secrets engine's HTTP API please see the Database secret secrets engine API page.

Edit this page on GitHub

On this page

  1. Couchbase Database Secrets Engine
  2. Capabilities
  3. Setup
  4. Usage
  5. API
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)