kv.v2.list_secrets fails when LIST request not supported #947
Replies: 3 comments
-
im having the same issue |
Beta Was this translation helpful? Give feedback.
-
Here's my quick&ugly workaround until the lib is fixed:
|
Beta Was this translation helpful? Give feedback.
-
Hi folks! We do have a method to force the use of import hvac
class StrictAdapter(hvac.adapters.JSONAdapter):
def __init__(self, *args, **kwargs):
kwargs["strict_http"] = True
super().__init__(*args, **kwargs)
client = hvac.Client(adapter=StrictAdapter) To follow the flow of how that's used: In the file linked in the OP, we see it the method call hvac/hvac/api/secrets_engines/kv_v2.py Line 330 in d7e9557
Line 162 in d7e9557 which in turn has code to check whether the method is Lines 295 to 301 in d7e9557 I think there's room for improvement here though. An overload, or a new parameter is not quite what I'd recommend, because all list methods would need the same thing, not just kv2, and the issue of needing to use Instead I'd probably look to make one or more of the following changes:
I'll think about it a bit and open an issue, and probably a PR. |
Beta Was this translation helpful? Give feedback.
-
I've stumbled upon a problem that when
LIST
request is not supported, the library cannot extract the list of secrets from Vault, while the default client can (because it usesGET
)kv.v2.list_secrets(path="mysecret")
will throw "Bad Request" exceptionThe problem is in this block:
https://github.com/hvac/hvac/blob/develop/hvac/api/secrets_engines/kv_v2.py#L328
Changing it to GET fixes the issue:
for the reference, the official client uses GET too:
It would be good to have an overloaded method that explicitly uses GET as a request
Beta Was this translation helpful? Give feedback.
All reactions