You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<dd>Caching mechanism adopted by Centralized Config Providers</dd>
@@ -215,19 +215,27 @@ For more information, visit the official documentation: <a href="https://develop
215
215
216
216
### HCP Vault Secrets
217
217
218
-
Authentication for the **HCP Vault Secrets**uses the OAuth 2.0 Client Credentials flow.
218
+
Authentication for **HCP Vault Secrets**supports two methods:
219
219
220
-
The `CLIENT_ID` and `CLIENT_SECRET` are used to obtain a Bearer token for authentication,
221
-
the Bearer token is then used for making API calls to retrieve secrets from HCP Vault Secrets.
222
-
Once authenticated, the secrets can be retrieved using the HashiCorp Vault API.
220
+
1.**OAuth 2.0 Client Credentials Flow**
221
+
- Uses `HCP_CLIENT_ID` and `HCP_CLIENT_SECRET`to obtain a Bearer token for authentication.
222
+
- The token is then used to retrieve secrets from HCP Vault Secrets API.
223
223
224
-
The generated token is cached and reused until it expires, minimizing API calls to the HCP Vault Secrets.
224
+
2.**Credentials File Authentication**
225
+
- Uses a JSON file (`creds-cache.json`) containing authentication credentials (`access_token`, `refresh_token`, and `access_token_expiry`). - If the access token is expired, it is automatically refreshed using the stored refresh token.
226
+
- If the access token is expired, it is **automatically refreshed** using the stored refresh token.
227
+
- This method allows authentication **without requiring direct API credentials**.
228
+
229
+
The generated token is cached and reused until it expires, minimizing API calls to HCP Vault Secrets.
225
230
226
231
Secrets can be retrieved from the following API endpoint:
For more information, visit the official HashiCorp Vault documentation: [HCP Vault Secrets](https://developer.hashicorp.com/hcp/tutorials/get-started-hcp-vault-secrets/hcp-vault-secrets-retrieve-secret).
230
235
236
+
#### OAuth 2.0 Client Credentials Flow
237
+
238
+
This method uses OAuth 2.0 **client credentials** to obtain a **Bearer token**, which is required for authentication.
231
239
The provider searches for the following parameters:
232
240
233
241
<table>
@@ -249,6 +257,66 @@ The provider searches for the following parameters:
249
257
<td>The client secret for OAuth 2.0 authentication</td>
250
258
<td>Yes</td>
251
259
</tr>
260
+
</tbody>
261
+
</table>
262
+
263
+
#### CLI CREDENTIALS FILE
264
+
This method **retrieves authentication details** from a **JSON file (`creds-cache.json`)** that contains access tokens.
265
+
266
+
- If **HCP CLI is installed**, a **creds-cache.json** file is **automatically created** in: <code>~/.config/hcp/creds-cache.json</code>
267
+
- This file contains **access_token, refresh_token, and access_token_expiry**.
268
+
- If **the token is expired**, it is **automatically refreshed** using the **refresh_token**.
269
+
- The credentials file should be a JSON file containing the following structure:
270
+
271
+
```json
272
+
{
273
+
"login": {
274
+
"access_token": "YOUR_ACCESS_TOKEN",
275
+
"refresh_token": "YOUR_REFRESH_TOKEN",
276
+
"access_token_expiry": "2025-01-01T12:34:56.789Z"
277
+
}
278
+
}
279
+
```
280
+
- access_token: The current access token for API authentication.
281
+
- refresh_token: The refresh token used to obtain a new access token when expired.
282
+
- access_token_expiry: The expiration timestamp of the access_token.
283
+
284
+
When using this method, the provider will:
285
+
* Read the file and validate the access_token.
286
+
* Refresh the token if it's expired, using the refresh_token.
287
+
* Update the file with the new token details.
288
+
289
+
The provider searches for the following parameters:
290
+
291
+
<table>
292
+
<thead>
293
+
<tr>
294
+
<th>Parameter Name</th>
295
+
<th>Description</th>
296
+
<th>Required</th>
297
+
</tr>
298
+
</thead>
299
+
<tbody>
300
+
<tr>
301
+
<td><code>HCP_CREDENTIALS_FILE</code></td>
302
+
<td>The path of the credentials file ( by default
303
+
<code>~/.config/hcp/creds-cache.json</code></td>
304
+
<td>No</td>
305
+
</tr>
306
+
</tbody>
307
+
</table>
308
+
309
+
#### Common Parameters for HCP Vault Secrets authentication methods
310
+
311
+
<table>
312
+
<thead>
313
+
<tr>
314
+
<th>Parameter Name</th>
315
+
<th>Description</th>
316
+
<th>Required</th>
317
+
</tr>
318
+
</thead>
319
+
<tbody>
252
320
<tr>
253
321
<td><code>HCP_ORG_ID</code></td>
254
322
<td>The organization ID associated with the Vault</td>
@@ -267,6 +335,7 @@ The provider searches for the following parameters:
267
335
</tbody>
268
336
</table>
269
337
338
+
270
339
## Config Providers
271
340
272
341
### HCP Vault Dedicated Config Provider
@@ -394,10 +463,14 @@ For the JSON type of provider (HCP Vault Dedicated, HCP Vault Secrets, HTTP/HTTP
394
463
- Secret name (if hcpvaultsecret)
395
464
- Text
396
465
- field_name (HCP Vault Dedicated only)
397
-
-Mandatory
466
+
-Optional
398
467
- Description: Specifies the key within the secret JSON object to retrieve the password value.
399
468
For example, if the secret contains `{ "db-password": "mypassword" }`,
400
-
setting `field_name: "db-password"` will extract `"mypassword"`.
469
+
setting `field_name: "db-password"` will extract `"mypassword"`.
470
+
-**Logic behind the `field_name` attribute:**
471
+
- If `field_name` is **specified**, its corresponding value is extracted.
472
+
- If the **secret contains only one key-value pair**, that value is **automatically used**.
473
+
- If `field_name` is **missing** and **multiple keys exist**, an **error is thrown**.
Copy file name to clipboardexpand all lines: ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultdedicated/configuration/DedicatedVaultJsonSecretProvider.java
+20-3
Original file line number
Diff line number
Diff line change
@@ -70,10 +70,18 @@
70
70
* }
71
71
* }</pre>
72
72
*
73
+
* <h3>Behavior for Extracting the Secret</h3>
74
+
* <ul>
75
+
* <li> If {@code field_name} is provided, the corresponding value is
76
+
* extracted.</li>
77
+
* <li>If the secret contains <b>only one key-value pair</b>, that value
78
+
* is automatically selected.</li>
79
+
* <li>If multiple keys exist and {@code field_name} is <b>not provided</b>,
80
+
* an error is thrown.</li>
81
+
* </ul>
73
82
* <p>
74
83
* The secret path specified in the JSON is used to query the Vault and fetch
75
-
* the desired secret. If {@code FIELD_NAME} is provided, the corresponding
76
-
* field is extracted from the Vault's JSON response.
Copy file name to clipboardexpand all lines: ojdbc-provider-hashicorp/src/main/java/oracle/jdbc/provider/hashicorp/hcpvaultsecret/authentication/HcpVaultAuthenticationMethod.java
+28-1
Original file line number
Diff line number
Diff line change
@@ -64,5 +64,32 @@ public enum HcpVaultAuthenticationMethod {
64
64
* by calling the HCP OAuth2 endpoint.
65
65
* </p>
66
66
*/
67
-
CLIENT_CREDENTIALS
67
+
CLIENT_CREDENTIALS,
68
+
69
+
/**
70
+
* Authentication using the credentials file generated by the HCP CLI.
71
+
* <p>
72
+
* This method retrieves an access token from the standard CLI-generated
0 commit comments