Valkey database secrets engine
Valkey is one of the supported plugins for the database secrets engine. This plugin generates database credentials dynamically based on configured roles for the Valkey database.
See the database secrets engine docs for more information about setting up the database secrets engine.
Capabilities
Plugin Name | Root Credential Rotation | Dynamic Roles | Static Roles | Username Customization |
---|---|---|---|---|
valkey-database-plugin | Yes | Yes | Yes | No |
Setup
-
Enable the database secrets engine if it is not already enabled:
$ bao 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. -
Configure OpenBao with the proper plugin and connection configuration:
$ bao write database/config/my-valkey-database \
plugin_name="valkey-database-plugin" \
host="localhost" \
port=6379 \
tls=true \
ca_cert="$CACERT" \
username="user" \
password="pass" \
allowed_roles="my-*-role" -
You should consider rotating the admin password. Note that if you do, the new password will never be made available through OpenBao, so you should create an OpenBao-specific database admin user for this.
$ bao write -force database/rotate-root/my-valkey-database
Usage
After the secrets engine is configured, write dynamic and static roles to OpenBao to enable generating credentials.
Dynamic roles
-
Configure a dynamic role that maps a name in OpenBao to a JSON string containing the Valkey ACL rules, which are either documented here or in the output of the
ACL CAT
Valkey command.$ bao write database/roles/my-dynamic-role \
db_name="my-valkey-database" \
creation_statements='["+@admin"]' \
default_ttl="5m" \
max_ttl="1h"
Success! Data written to: database/roles/my-dynamic-roleNote that if a creation_statement is not provided the user account will default to a read only user,
'["~*", "+@read"]'
that can read any key. -
Generate a new set of credentials by reading from the
/creds
endpoint with the name of the role:$ bao read database/creds/my-dynamic-role
Key Value
--- -----
lease_id database/creds/my-dynamic-role/OxCTXJcxQ2F4lReWPjbezSnA
lease_duration 5m
lease_renewable true
password dACqHsav6-attdv1glGZ
username V_TOKEN_MY-DYNAMIC-ROLE_YASUQUF3GVVD0ZWTEMK4_1608481717
Static roles
-
Configure a static role that maps a name in OpenBao to an existing Valkey user.
$ bao write database/static-roles/my-static-role \
db_name="my-valkey-database" \
username="my-existing-valkey-user" \
rotation_period=5m
Success! Data written to: database/static-roles/my-static-role -
Retrieve the credentials from the
/static-creds
endpoint:$ bao read database/static-creds/my-static-role
Key Value
--- -----
last_vault_rotation 2020-12-20T10:39:49.647822-06:00
password ylKNgqa3NPVAioBf-0S5
rotation_period 5m
ttl 4m39s
username my-existing-valkey-user
API
The full list of configurable options can be seen in the Valkey Database Plugin API page.
For more information on the database secrets engine's HTTP API please see the Database Secrets Engine API page.