Skip to main content
Version: Development

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.

MethodPath
POST/database/config/:name

Parameters

  • connection_url (string: <required>) – Specifies the Oracle connection string, in the oracle://{{username}}:{{password}}@host:port/service format (any DSN accepted by the go-ora driver is valid). This field can be templated and supports passing the username and password parameters 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 of max_open_connections and a negative value disables idle connections. If larger than max_open_connections it 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 (often SYSTEM) 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 — SELECT on v$session and ALTER SYSTEM.

  • password (string: <required>) – Specifies the root credential password corresponding to username.

  • 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 to false.

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
DisplayNametoken
RoleNamemyrole
UsernameV_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, formatted 2006-01-02 15:04:05. This value is informational only: Oracle has no native VALID UNTIL on 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 without creation_statements fails 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:

    1. Query v$session for active sessions belonging to the user and issue ALTER SYSTEM KILL SESSION '<sid>,<serial#>' IMMEDIATE for each one found (so DROP USER doesn't fail with ORA-01940). This step is best-effort — if the configured root lacks SELECT on v$session the query error is swallowed and revocation falls through to the drop.
    2. DROP USER "<quoted-username>" CASCADE, dropping the user's schema and any objects it owns.
  • 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 via database/rotate-root/:name (see Configure connection). The {{username}} and {{password}} values will be substituted. If not provided, uses the same default as rotation_statements.

rollback_statements is accepted by the database secrets engine framework but is not used by this plugin.