DEV Community

loading...
Cover image for If I know a Vault CLI command, how do I get its cURL Command?

If I know a Vault CLI command, how do I get its cURL Command?

πŸ¦„N BπŸ›‘
// , β€œIt is not so important to be serious as it is to be serious about the important things. The monkey wears an expression of seriousness... but the monkey is serious because he itches."(No/No)
・1 min read

If you have a command like vault auth enable oidc, how do you know its corresponding API call? Like this:

vault auth disable -output-curl-string oidc

Here's an example:

$ vault auth enable oidc
Success! Enabled oidc auth method at: oidc/

$ vault auth disable oidc
Success! Disabled the auth method (if it existed) at: oidc/

$ vault auth enable -output-curl-string oidc
curl -X POST -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)"
 -d '{"type":"oidc","description":"","config":{"options":null,"default_lease_ttl
":"0s","max_lease_ttl":"0s","force_no_cache":false},"local":false,"seal_wrap":fa
lse,"external_entropy_access":false,"options":null}' http://127.0.0.1:8200/v1/sy
s/auth/oidc

$ vault auth disable -output-curl-string oidc
curl -X DELETE -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token
)" http://127.0.0.1:8200/v1/sys/auth/oidc

Enter fullscreen mode Exit fullscreen mode

For more on the easy way to use the Vault API got get or generate "Secrets," I recommend this link:

https://www.slideshare.net/mitchp/vault-secrets-via-api-for-the-rest-of-us

Discussion (0)