SAP HANA database secrets engine
SAP HANA is one of the supported plugins for the database secrets engine. This plugin generates SAP HANA user credentials dynamically based on configured roles, and also supports Static Roles.
See the database secrets engine docs for more information about setting up the database secrets engine.
SAP HANA identifiers are case-folded to uppercase and reject hyphens, so generated usernames are always uppercased with any hyphens replaced by underscores before they are sent to HANA.
Capabilities
| Plugin Name | Root Credential Rotation | Dynamic Roles | Static Roles | Username Customization |
|---|---|---|---|---|
hana-database-plugin | Yes | Yes | Yes | 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/my-hana-database \plugin_name="hana-database-plugin" \allowed_roles="my-role" \connection_url="hdb://{{username}}:{{password}}@hana.example.com:39041" \username="SYSTEM" \password="your-system-password"Success! Data written to: database/config/my-hana-database -
Configure a role that maps a name in OpenBao to an SQL statement to execute to create the database credential:
$ bao write database/roles/my-role \db_name="my-hana-database" \creation_statements='CREATE USER {{name}} PASSWORD "{{password}}" NO FORCE_FIRST_PASSWORD_CHANGE VALID UNTIL '"'"'{{expiration}}'"'"';GRANT SELECT ON SCHEMA SYSTEM TO {{name}};' \default_ttl="1h" \max_ttl="24h"Success! Data written to: database/roles/my-roleThe
{{name}}and{{password}}fields will be populated by the plugin with dynamically generated values. The{{expiration}}field is also supported and is formatted2006-01-02 15:04:05(UTC). HANA enforces theVALID UNTILclause server-side, so the role's own creation statement is enough to deactivate the user even without an explicit revoke.
Usage
After the secrets engine is configured and a user/machine has an OpenBao token with the proper permission, it can generate credentials.
-
Generate a new credential by reading from the
/credsendpoint with the name of the role:$ bao read database/creds/my-roleKey Value--- -----lease_id database/creds/my-role/2f6a614c-4aa2-7b19-24b9-ad944a8d4de6lease_duration 1hlease_renewable truepassword AbCdEf1234567890QwRtYiusername V_TOKEN_MY_ROLE_3PFW6T8RVMC8MBKZ8ZEF_1717000000The username is uppercased and underscore-separated because HANA identifiers are case-folded and reject hyphens.
API
The full list of configurable options can be seen in the SAP HANA database plugin API page.
For more information on the database secrets engine's HTTP API please see the Database secrets engine API page.