From f9e3b396c0b13862417c48b08eb91ab235090046 Mon Sep 17 00:00:00 2001 From: Srigovind Nayak Date: Sun, 8 Sep 2024 11:20:31 +0530 Subject: [PATCH] fix: update HTTP method from LIST to GET for ReadSecretPathsAsync (#329) * fix: update HTTP method from LIST to GET * add query parameter ?list=true Ref: https://developer.hashicorp.com/vault/api-docs#api-operations * chore: update changelog for release --- CHANGELOG.md | 1 + .../KeyValue/V2/KeyValueSecretsEngineV2Provider.cs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b676787..b8ed3a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * [GH-309](https://github.com/rajanadar/VaultSharp/issues/309) identity/oidc/key: create, read, update and delete apis. * [GH-309](https://github.com/rajanadar/VaultSharp/issues/309) identity/oidc/role: create, read, update and delete apis. * [GH-309](https://github.com/rajanadar/VaultSharp/issues/309) auth/approle: ````PullNewSecretIdAsync``` allows for reponse wrapping using ```wrapTimeToLive``` parameter + * [GH-329](https://github.com/rajanadar/VaultSharp/issues/329) kv2/metadata: `ReadSecretPathsAsync` to use HTTP `GET` method and `?list=true` instead of non-standard HTTP verb `LIST` ## 1.13.0.1 (April 03, 2023) diff --git a/src/VaultSharp/V1/SecretsEngines/KeyValue/V2/KeyValueSecretsEngineV2Provider.cs b/src/VaultSharp/V1/SecretsEngines/KeyValue/V2/KeyValueSecretsEngineV2Provider.cs index ceebb69..ee033d8 100644 --- a/src/VaultSharp/V1/SecretsEngines/KeyValue/V2/KeyValueSecretsEngineV2Provider.cs +++ b/src/VaultSharp/V1/SecretsEngines/KeyValue/V2/KeyValueSecretsEngineV2Provider.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; using VaultSharp.Core; @@ -109,7 +110,9 @@ public async Task> ReadSecretPathsAsync(string path, string mou { Checker.NotNull(path, "path"); - return await _polymath.MakeVaultApiRequest>(mountPoint ?? _polymath.VaultClientSettings.SecretsEngineMountPoints.KeyValueV2, "/metadata/" + path.Trim('/'), _polymath.ListHttpMethod, wrapTimeToLive: wrapTimeToLive).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); + string queryParameters = "?list=true"; + + return await _polymath.MakeVaultApiRequest>(mountPoint ?? _polymath.VaultClientSettings.SecretsEngineMountPoints.KeyValueV2, "/metadata/" + path.Trim('/') + queryParameters, HttpMethod.Get, wrapTimeToLive: wrapTimeToLive).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); } public async Task> ReadSecretMetadataAsync(string path, string mountPoint = null, string wrapTimeToLive = null)