vault/api
Bruno Oliveira de Souza 0b9157156f
VAULT-32657 deprecate duplicate attributes in HCL configs and policies (#30386)
* upgrade hcl dependency on api pkg

This upgrades the hcl dependency for the API pkg,
and adapts its usage so users of our API pkg are
not affected. There's no good way of communicating
a warning via a library call so we don't.

The tokenHelper which is used by all Vault CLI
commands in order to create the Vault client, as
well as directly used by the login and server
commands, is implemented on the api pkg, so this
upgrade also affects all of those commands. Seems
like this was only moved to the api pkg because
the Terraform provider uses it, and I thought
creating a full copy of all those files back under
command would be too much spaghetti.

Also leaving some TODOs to make next deprecation
steps easier.

* upgrade hcl dependency in vault and sdk pkgs

* upgrade hcl dependency in vault and sdk pkgs

* add CLI warnings to commands that take a config

- vault agent (unit test on CMD warning)
- vault proxy (unit test on CMD warning)
- vault server (no test for the warning)
- vault operator diagnose (no tests at all, uses the
same function as vault server

* ignore duplicates on ParseKMSes function

* Extend policy parsing functions and warn on policy store

* Add warning on policy fmt with duplicate attributes

* Add warnings when creating/updating policy with duplicate HCL attrs

* Add log warning when switchedGetPolicy finds duplicate attrs

Following operations can trigger this warning when they run into a policy
with duplicate attributes:
* replication filtered path namespaces invalidation
* policy read API
* building an ACL (for many different purposes like most authZ operations)
* looking up DR token policies
* creating a token with named policies
* when caching the policies for all namespaces during unseal

* Print log warnings when token inline policy has duplicate attrs

No unit tests on these as new test infra would have to be built on all.
Operations affected, which will now print a log warning when the retrieved
token has an inline policy with duplicate attributes:
* capabilities endpoints in sys mount
* handing events under a subscription with a token with duplicate
attrs in inline policies
* token used to create another token has duplicate attrs in inline
policies (sudo check)
* all uses of fetchACLTokenEntryAndEntity when the request uses a
token with inline policies with duplicate attrs. Almost all reqs
are subject to this
* when tokens are created with inline policies (unclear exactly how that
can happen)

* add changelog and deprecation notice

* add missing copywrite notice

* fix copy-paste mistake

good thing it was covered by unit tests

* Fix manual parsing of telemetry field in SharedConfig

This commit in the hcl library was not in the
v1.0.1-vault-5 version we're using but is
included in v1.0.1-vault-7:
e80118accb

This thing of reusing when parsing means that
our approach of manually re-parsing fields
on top of fields that have already been parsed
by the hcl annotation causes strings (maybe
more?) to concatenate.

Fix that by removing annotation. There's
actually more occurrences of this thing of
automatically parsing something that is also
manually parsing. In some places we could
just remove the boilerplate manual parsing, in
others we better remove the auto parsing, but
I don't wanna pull at that thread right now. I
just checked that all places at least fully
overwrite the automatically parsed field
instead of reusing it as the target of the
decode call. The only exception is the AOP
field on ent but that doesn't have maps or
slices, so I think it's fine.

An alternative approach would be to ensure
that the auto-parsed value is discarded,
like the current parseCache function does

note how it's template not templates

* Fix linter complaints

* Update command/base_predict.go

Co-authored-by: Mike Palmiotto <mike.palmiotto@hashicorp.com>

* address review

* remove copywrite headers

* re-add copywrite headers

* make fmt

* Update website/content/partials/deprecation/duplicate-hcl-attributes.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/partials/deprecation/duplicate-hcl-attributes.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/partials/deprecation/duplicate-hcl-attributes.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* undo changes to deprecation.mdx

* remove deprecation doc

* fix conflict with changes from main

---------

Co-authored-by: Mike Palmiotto <mike.palmiotto@hashicorp.com>
Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>
2025-05-23 16:02:07 -03:00
..
auth Rework certificate authentication client api (#29931) 2025-03-14 15:48:52 -04:00
cliconfig VAULT-32657 deprecate duplicate attributes in HCL configs and policies (#30386) 2025-05-23 16:02:07 -03:00
test-fixtures VAULT-32657 deprecate duplicate attributes in HCL configs and policies (#30386) 2025-05-23 16:02:07 -03:00
tokenhelper Directly exec ExternalTokenHelper rather than using a SHELL (#29653) 2025-04-04 14:34:26 -04:00
.copywrite.hcl [DO NOT MERGE UNTIL EOY] update year in LICENSE and copywrite files (#24368) 2024-01-02 13:22:15 -08:00
api_test.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
auth_test.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
auth_token.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
auth.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
client_test.go Specify headers by environment variable (#21993) 2024-06-19 16:51:24 -04:00
client.go explain how -output-curl-string works in comments to avoid confusion (#28576) 2024-10-04 11:14:21 -07:00
go.mod VAULT-32657 deprecate duplicate attributes in HCL configs and policies (#30386) 2025-05-23 16:02:07 -03:00
go.sum VAULT-32657 deprecate duplicate attributes in HCL configs and policies (#30386) 2025-05-23 16:02:07 -03:00
hcl_dup_attr_deprecation.go VAULT-32657 deprecate duplicate attributes in HCL configs and policies (#30386) 2025-05-23 16:02:07 -03:00
help.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
kv_test.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
kv_v1.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
kv_v2.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
kv.go docs: Update outdated vaultproject.io/docs/ links (#22162) 2023-08-15 12:59:34 -04:00
LICENSE [COMPLIANCE] License changes (#22290) 2023-08-10 18:14:03 -07:00
lifetime_watcher.go Bump backoff/v3 to backoff/v4 (#26868) 2024-05-29 12:04:46 -04:00
logical.go VAULT-36198: Add API/CLI support for reading, listing, recovering from a snapshot (#30701) 2025-05-21 15:10:20 +02:00
output_policy_test.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
output_policy.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
output_string.go explain how -output-curl-string works in comments to avoid confusion (#28576) 2024-10-04 11:14:21 -07:00
plugin_helpers.go Upgrade api package go-jose to v4 (#26527) 2024-04-19 12:17:41 +01:00
plugin_runtime_types.go Use enumer to generate String() methods for most enums (#25705) 2024-04-17 11:14:14 -07:00
plugin_types_test.go New root namespace plugin reload API sys/plugins/reload/:type/:name (#24878) 2024-01-17 15:46:27 +00:00
plugin_types.go New root namespace plugin reload API sys/plugins/reload/:type/:name (#24878) 2024-01-17 15:46:27 +00:00
pluginruntimetype_enumer.go Use enumer to generate String() methods for most enums (#25705) 2024-04-17 11:14:14 -07:00
README.md docs: Update outdated vaultproject.io/docs/ links (#22162) 2023-08-15 12:59:34 -04:00
renewbehavior_enumer.go Use enumer to generate String() methods for most enums (#25705) 2024-04-17 11:14:14 -07:00
renewer_test.go VAULT-25341 Address issue where having no permissions to renew caused auto-auth to attempt to renew with no backoff (#26844) 2024-05-09 11:12:42 -04:00
replication_status.go CE part of https://github.com/hashicorp/vault-enterprise/pull/4269 (#26406) 2024-04-15 20:08:57 +00:00
request_test.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
request.go chore: fix deprecated ioutil nopcloser (#27650) 2024-07-03 13:38:34 -04:00
response.go chore: fix deprecated ioutil nopcloser (#27650) 2024-07-03 13:38:34 -04:00
secret_test.go Relplat 897 copywrite fixes for mutliple licenses (#23722) 2023-10-20 08:40:43 -07:00
secret.go Prepare code base for Go 1.24 update. (#29412) 2025-01-27 14:34:07 -05:00
ssh_agent_test.go VAULT-32657 deprecate duplicate attributes in HCL configs and policies (#30386) 2025-05-23 16:02:07 -03:00
ssh_agent.go VAULT-32657 deprecate duplicate attributes in HCL configs and policies (#30386) 2025-05-23 16:02:07 -03:00
ssh.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sudo_paths_test.go add plugin runtime API (#22469) 2023-08-31 13:37:04 -07:00
sudo_paths.go Add non-root access with filtering support to activity export API (#27846) 2024-07-24 09:21:52 -04:00
sys_audit.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_auth.go api: do not require sudo for GetAuth wrapper (#25968) 2024-03-15 14:40:22 -07:00
sys_capabilities.go Command: token capabilities using accessor (#24479) 2023-12-13 11:15:21 -05:00
sys_config_cors.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_generate_root.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_hastatus.go CE part of https://github.com/hashicorp/vault-enterprise/pull/4269 (#26406) 2024-04-15 20:08:57 +00:00
sys_health.go VAULT-31755: Add removed and HA health to the sys/health endpoint (#28991) 2024-12-04 11:09:10 +01:00
sys_init.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_leader.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_leases.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_mfa.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_monitor.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_mounts_test.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_mounts.go Support trimming trailing slashes via a mount tuneable to support CMPv2 (#28752) 2024-10-24 10:47:17 -05:00
sys_plugins_runtimes_test.go add plugin runtime API (#22469) 2023-08-31 13:37:04 -07:00
sys_plugins_runtimes.go Support rootless plugin containers (#24236) 2023-11-28 14:07:07 +00:00
sys_plugins_test.go Vault 18538 reference runtime on plugin register (#22744) 2023-09-06 23:37:10 -07:00
sys_plugins.go New root namespace plugin reload API sys/plugins/reload/:type/:name (#24878) 2024-01-17 15:46:27 +00:00
sys_policy.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_raft.go [VAULT-35076] Add methods for loading and unloading snapshots to the sys raft API client (#30719) 2025-05-22 16:54:26 +01:00
sys_rekey.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_rotate.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_seal.go VAULT-31751, VAULT-31752: removed_from_cluster in vault status (#28938) 2024-11-19 11:13:10 +01:00
sys_stepdown.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00
sys_ui_custom_message_test.go VAULT-22504: Support Custom Messages in api Package (#24959) 2024-01-23 13:20:58 -05:00
sys_ui_custom_message.go VAULT-22504: Support Custom Messages in api Package (#24959) 2024-01-23 13:20:58 -05:00
sys_utilization_report.go VAULT-34541 CE changes (#29920) 2025-03-18 16:01:59 -04:00
sys.go adding copyright header (#19555) 2023-03-15 09:00:52 -07:00

Vault API

This provides the github.com/hashicorp/vault/api package which contains code useful for interacting with a Vault server.

For examples of how to use this module, see the vault-examples repo. For a step-by-step walkthrough on using these client libraries, see the developer quickstart.

GoDoc