Weaviate database secrets engine
Weaviate is one of the supported plugins for the database secrets engine.
For Weaviate v1.30+ with AUTHENTICATION_DB_USERS_ENABLED=true and
AUTHORIZATION_ENABLE_RBAC=true, this plugin supports dynamic credentials
via Weaviate's User Management and RBAC REST APIs:
Initialize(andVerifyConnection) call the configured server's/v1/.well-known/readyendpoint, sending the configuredapi_keyas a Bearer token, to confirm the server is reachable and that the key is accepted.- Dynamic credentials (
bao read database/creds/...) generate a unique username, create the user viaPOST /v1/users/db/{user_id}, assign roles configured increation_statementsviaPOST /v1/authz/users/{id}/assign, and return Weaviate's generated API key inpassword. - Deletion (
DeleteUser) deletes the user from Weaviate viaDELETE /v1/users/db/{user_id}when the lease expires or is revoked.
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 |
|---|---|---|---|---|
weaviate-database-plugin | No | Yes | No | Yes |
Setup
-
Enable the database secrets engine if it is not already enabled:
$ bao secrets enable databaseSuccess! 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
-pathargument. -
Configure OpenBao with the proper plugin and connection information:
$ bao write database/config/weaviate \plugin_name="weaviate-database-plugin" \url="https://weaviate.example.com:8080" \api_key="admin-key" \allowed_roles="app"Success! Data written to: database/config/weaviate -
Configure a dynamic role with the roles assigned in
creation_statements:$ bao write database/roles/app \db_name="weaviate" \creation_statements='{"roles": ["viewer"]}' \default_ttl="1h" \max_ttl="24h"Success! Data written to: database/roles/appCustom roles can also be declared inline under
custom_roles:$ bao write database/roles/app \db_name="weaviate" \creation_statements='{"roles": ["viewer"], "custom_roles": [{"name": "customrole", "permissions": [{"action": "read_data", "collections": {"collection": "Products"}}]}]}' \default_ttl="1h" \max_ttl="24h"Success! Data written to: database/roles/app
Usage
After the secrets engine is configured and a user/machine has an OpenBao token with the proper permission, it can generate dynamic credentials.
-
Generate dynamic credentials by reading from the
/credsendpoint with the name of the role:$ bao read database/creds/appKey Value--- -----lease_id database/creds/app/0c65456d-70ad-4af6-b5b8-0afe017ae517lease_duration 1hlease_renewable truepassword weaviate-user-api-key-...username v-kubernet-k8s.53e2-gsw5HQPaxEPROnaZAWuZ-1788435207The
passwordfield contains Weaviate's generated API key, which can be presented to Weaviate in theAuthorization: Bearer <token>header. -
To revoke credentials before lease expiry:
$ bao lease revoke database/creds/app/0c65456d-70ad-4af6-b5b8-0afe017ae517Success! Revoked lease: database/creds/app/0c65456d-70ad-4af6-b5b8-0afe017ae517