SAP HANA database plugin HTTP API
The SAP HANA database plugin is one of the supported plugins for the database secrets engine. This plugin generates database credentials dynamically based on configured roles for the SAP HANA database.
Configure connection
In addition to the parameters defined by the Database Backend, this plugin has a number of parameters to further configure a connection.
| Method | Path |
|---|---|
POST | /database/config/:name |
Parameters
-
connection_url(string: <required>)– Specifies the HANA connection string, in thehdb://{{username}}:{{password}}@host:portformat (the HDB protocol port, typically3<NN>15). This field can be templated and supports passing theusernameandpasswordparameters in the{{field_name}}format. A templated connection URL is required when using root credential rotation. -
max_open_connections(int: 4)– Specifies the maximum number of open connections to the database. -
max_idle_connections(int: 0)– Specifies the maximum number of idle connections to the database. A zero uses the value ofmax_open_connectionsand a negative value disables idle connections. If larger thanmax_open_connectionsit will be reduced to be equal. -
max_connection_lifetime(string: "0s")– Specifies the maximum amount of time a connection may be reused. If <=0s, connections are reused forever. -
username(string: <required>)– Specifies the root credential username OpenBao uses to log into HANA and issue/revoke dynamic users. This account must holdUSER ADMINor equivalent privileges to run the defaultDEACTIVATE/DROP USERrevocation statements. -
password(string: <required>)– Specifies the root credential password corresponding tousername. -
username_template(string)- Template describing how dynamic usernames are generated. After template rendering, the plugin additionally replaces any hyphens with underscores and uppercases the result, since HANA identifiers are case-folded to uppercase and reject hyphens. -
disable_escaping(boolean: false)– Turns off the escaping of special characters inside of the username and password fields. See the databases secrets engine docs for more information. Defaults tofalse.
Default Username Template
{{ printf "v_%s_%s_%s_%s" (.DisplayName | truncate 32) (.RoleName | truncate 20) (random 20) (unix_time) | truncate 127 | replace "-" "_" | uppercase }}
Example Usernames:
| Example | |
|---|---|
DisplayName | token |
RoleName | myrolename |
| Username | V_TOKEN_MYROLENAME_USZT1N4CYHAL4M0XTGX3_1614294836 |
Sample payload
{
"plugin_name": "hana-database-plugin",
"allowed_roles": "readonly",
"connection_url": "hdb://{{username}}:{{password}}@hana.example.com:39041",
"username": "SYSTEM",
"password": "your-system-password"
}
Sample request
$ curl \
--header "X-Vault-Token: ..." \
--request POST \
--data @payload.json \
http://127.0.0.1:8200/v1/database/config/my-hana-database
Statements
Statements are configured during role creation and are used by the plugin to determine what is sent to the database on user creation, renewing, and revocation. For more information on configuring roles see the Role API in the database secrets engine docs.
Every statement below is split on ; and executed as its own query within a
single transaction. The following placeholders are substituted:
{{name}}– the generated username (uppercased, underscore-separated){{username}}– alias of{{name}}, used by the rotation and renewal statements{{password}}– the generated password{{expiration}}– the expiration timestamp, formatted2006-01-02 15:04:05(UTC)
Parameters
The following are the statements used by this plugin. If not mentioned in this list the plugin does not support that statement type.
-
creation_statements(list: <required>)– Specifies the database statements executed to create and configure a user. Must be a semicolon-separated string, a base64-encoded semicolon-separated string, a serialized JSON string array, or a base64-encoded serialized JSON string array. The{{name}},{{password}}, and{{expiration}}values will be substituted. There is no built-in default; a role withoutcreation_statementsfails to issue credentials. Recommended statement:CREATE USER {{name}} PASSWORD "{{password}}" NO FORCE_FIRST_PASSWORD_CHANGE VALID UNTIL '{{expiration}}';GRANT <required-privileges> TO {{name}}; -
revocation_statements(list: [])– Specifies the database statements to be executed to revoke a user. Must be a semicolon-separated string, a base64-encoded semicolon-separated string, a serialized JSON string array, or a base64-encoded serialized JSON string array. The{{name}}value will be substituted. If not provided, defaults to a soft-drop:ALTER USER "<username>" DEACTIVATE USER NOW;DROP USER "<username>" RESTRICT;RESTRICTfails if the user still owns objects. For a hard drop, supply explicitrevocation_statementscontainingDROP USER {{name}} CASCADE;. The identifier is quoted server-side to prevent SQL injection via the generated username. -
rotation_statements(list: [])– Specifies the database statements executed to rotate the password for a static role. The{{name}},{{username}}, and{{password}}values will be substituted. If not provided, defaults to:ALTER USER "{{username}}" PASSWORD "{{password}}" NO FORCE_FIRST_PASSWORD_CHANGE; -
renew_statements(list: [])– Specifies the database statements executed to extend a dynamic user's expiration when its lease is renewed. The{{name}},{{username}}, and{{expiration}}values will be substituted. If not provided, defaults to:ALTER USER "{{username}}" VALID UNTIL '{{expiration}}'; -
root_rotation_statements(list: [])– Specifies the database statements executed when rotating the root user's password viadatabase/rotate-root/:name(see Configure connection). The{{username}}and{{password}}values will be substituted. If not provided, uses the same default asrotation_statements.
rollback_statements is accepted by the database secrets engine framework but
is not used by this plugin.