Oracle database plugin HTTP API
The Oracle database plugin is one of the supported plugins for the database
secrets engine. This plugin generates database credentials dynamically based
on configured roles for Oracle Database, using the pure-Go
sijms/go-ora driver (no Oracle Instant
Client required).
Configure connection
In addition to the parameters defined by the Database Secrets Engine, 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 Oracle connection string, in theoracle://{{username}}:{{password}}@host:port/serviceformat (any DSN accepted by thego-oradriver is valid). This field can be templated and supports passing theusernameandpasswordparameters in the{{field_name}}format. -
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 Oracle and issue/revoke dynamic users. This account (oftenSYSTEM) must hold sufficient privileges to create and drop users and grant roles, and — for the default revocation path to be able to terminate active sessions before dropping a user —SELECTonv$sessionandALTER SYSTEM. -
password(string: <required>)– Specifies the root credential password corresponding tousername. -
username_template(string)- Template describing how dynamic usernames are generated. The rendered result is post-processed: hyphens and periods are replaced with underscores and the value is upper-cased, since Oracle identifiers are case-folded to upper-case unless double-quoted. -
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 8) (.RoleName | truncate 8) (random 8) (unix_time) | truncate 30 | replace "-" "_" | replace "." "_" | uppercase }}
30 characters is the historical Oracle identifier limit; the template is
truncated to that length for the widest compatibility across Oracle
versions.Example Usernames:
Example DisplayNametokenRoleNamemyroleUsername V_TOKEN_MYROLE_A1B2C3D4_1717000000 (truncated to 30 chars)
Sample payload
{
"plugin_name": "oracle-database-plugin",
"allowed_roles": "readonly",
"connection_url": "oracle://{{username}}:{{password}}@oracle.example.com:1521/XEPDB1",
"username": "SYSTEM",
"password": "oracle"
}
Sample request
$ curl \
--header "X-Vault-Token: ..." \
--request POST \
--data @payload.json \
http://127.0.0.1:8200/v1/database/config/my-oracle-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, rotation, 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 each resulting query executed
individually — Oracle DDL (such as CREATE USER) auto-commits and cannot
share a meaningful transaction with other statements, so each query runs as
its own unit. The following placeholders are substituted:
{{name}}– the generated username, used by the creation and revocation statements{{username}}– alias of{{name}}, used by the rotation and root rotation statements{{password}}– the generated (or rotated) password{{expiration}}– the expiration timestamp, formatted2006-01-02 15:04:05. This value is informational only: Oracle has no nativeVALID UNTILon users, so OpenBao's lease and its revocation of the user at expiry are what actually bound the credential's lifetime.
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}},{{username}},{{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}} IDENTIFIED BY "{{password}}";GRANT CREATE SESSION TO {{name}};GRANT SELECT, INSERT, UPDATE, DELETE ON some.table TO {{name}};If any statement in the list fails, the plugin still returns the generated username along with the error so that the lease revocation path can clean up the partially-created user.
-
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}}/{{username}}values will be substituted. If not provided, the plugin runs its default revoke instead:- Query
v$sessionfor active sessions belonging to the user and issueALTER SYSTEM KILL SESSION '<sid>,<serial#>' IMMEDIATEfor each one found (soDROP USERdoesn't fail withORA-01940). This step is best-effort — if the configured root lacksSELECTonv$sessionthe query error is swallowed and revocation falls through to the drop. DROP USER "<quoted-username>" CASCADE, dropping the user's schema and any objects it owns.
- Query
-
rotation_statements(list: [])– Specifies the database statements executed to rotate the password for a static role. The{{username}}and{{password}}values will be substituted. If not provided, defaults to:ALTER USER {{username}} IDENTIFIED BY "{{password}}"; -
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.