1853 Commits

Author SHA1 Message Date
Christopher Swenson
8f6dfaaf67
Interface for event subscription plugins; SQS plugin (#24352)
Initial version of an internal plugin interface for event subscription plugins,
and an AWS SQS plugin as an example.

Co-authored-by: Tom Proctor <tomhjp@users.noreply.github.com>
2024-02-05 13:17:07 -08:00
Mike Palmiotto
d75b5ed912
Initialize license in command_testonly for enterprise (#25175) 2024-02-01 19:03:29 +00:00
Kit Haines
99c74f5c80
Base Binary Cert and CSR Parse functions. (#24958)
* Base Binary Cert and CSR Parse functions.

* Add otherSANS parsing.

* Notate what doesn't exist on a CSR.

* Fix otherSans call err-checking and add basic-constriants to CSR

* Move BasicConstraint parsing to be optionally set.

* Refactored to use existing ParseBasicConstraintsExtension.

* Add handling for the ChangeSubjectName ext on CSR that is needed for EST

* Remove ChangeSubjectName - it's an attribute, not an extension, and there is no clean way to parse it, so pair down for now.

* Make these public methods, so they can be used in vault.

* Add unit tests for certutil.ParseCertificateToCreationParameters.

Also add unit tests for certutil.ParseCertificateToFields.

* Cleanup TestParseCertificate.

* Add unit tests for certutil.ParseCsrToCreationParameters and ParseCsrToFields.

* Fix return values for  "add_basic_constraints" in certutil.ParseCsrToFields.

Add a test for parsing CSRs where "add_basic_constraints" is false.

* Clear up some todos.

* Add a test for certutil.ParseCertificateToCreationParameters for non-CA cert.

* Tweak TestParseCertificate/full_non_CA_cert.

* Basics of three remaining fields - keyUsage; extKeyUsage; PolicyIdentifiers

* Fix tests and err handling

* Add unit tests for policy_identifiers; ext_key_usage_oids; key_usage

* Add test on ext_key_usage_oids

* Remove duplicate usages elsewhere.

* Add error handling to csr-checks.

* Remove extranames on returned types.

* Remove useless function.

---------

Co-authored-by: Victor Rodriguez <vrizo@hashicorp.com>
2024-02-01 10:03:43 -05:00
Mike Palmiotto
e4a11ae7cd
Request Limiter Reload tests (#25126)
This PR introduces a new testonly endpoint for introspecting the
RequestLimiter state. It makes use of the endpoint to verify that changes to
the request_limiter config are honored across reload.

In the future, we may choose to make the sys/internal/request-limiter/status
endpoint available in normal binaries, but this is an expedient way to expose
the status for testing without having to rush the design.

In order to re-use as much of the existing command package utility funcionality
as possible without introducing sprawling code changes, I introduced a new
server_util.go and exported some fields via accessors.

The tests shook out a couple of bugs (including a deadlock and lack of
locking around the core limiterRegistry state).
2024-02-01 09:11:08 -05:00
Scott Miller
f0e7f114a1
Avoid unnecessary rewraps, CE side (#25144)
* Avoid unnecessary rewraps, CE side

* sealRewrap is only available ENT side

* update stub

* update stub, again
2024-01-31 17:27:52 -06:00
Violet Hynes
1cb960d0f7
Fix data race with readable paths in our tests (#25127)
* Fix data race with readable paths in our tests

* Actually fix the issue
2024-01-30 14:33:06 +00:00
Tom Proctor
6e111d92fe
Support setting plugin TMPDIR in config as well as env (#24978) 2024-01-30 13:10:23 +00:00
akshya96
3b357e2314
manual reporting cli oss changes (#25109) 2024-01-26 13:00:38 -08:00
Mike Palmiotto
12f69a8ce5
Request Limiter listener config opt-out (#25098)
This commit introduces a new listener config option to allow disabling the request limiter per-listener.
2024-01-26 15:24:32 -05:00
Mike Palmiotto
5933768ca5
Request Limiter reloadable config (#25095)
This commit introduces a new reloadable stanza to the server config to allow disabling the Request Limiter.
2024-01-26 15:01:47 -05:00
indjb
b87318b35e
Apply default MaxConnsPerHost in agent even if template_config block is missing (#24989) 2024-01-24 12:56:05 -05:00
Austin Gebauer
a93ee17946
cli: adds plugin identity token to enable and tune commands for secret engines and auth methods (#24980)
* adds plugin identity token to secrets CLI for enable and tune

* adds plugin identity token to auth CLI for enable and tune

* adds field to mount config input and output

* adds changelog

* fix tests

* fix another test
2024-01-22 16:00:03 -08:00
Kit Haines
fb71d7f3c8
make-fmt (#24940) 2024-01-18 20:00:00 +00:00
Tom Proctor
80f85a05f6
New root namespace plugin reload API sys/plugins/reload/:type/:name (#24878) 2024-01-17 15:46:27 +00:00
Tom Proctor
f393241bb2
List plugin runtimes API always includes a list even if empty (#24864) 2024-01-16 16:36:07 +00:00
Violet Hynes
9e62680e10
Fix Agent and Proxy env var handling (#24790)
* Fix Agent and Proxy env var handling

* Changelog

* Review suggestions
2024-01-11 08:56:50 -05:00
Bianca Moreira
e0216cab5b
Add HCP subcommand -- integrate with HCP library (#23897)
* Add HCP engine token logic

* Update documentation

* Fix content check

* Add changelog entry

* Update changelog/23897.txt

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>

* Update api/client.go

Co-authored-by: Chris Capurso <1036769+ccapurso@users.noreply.github.com>

* Add error when HCP commands failed to be initialize

* Add tests for initHCPcommand function

* Update lib dependency

* Update website/content/docs/commands/hcp.mdx

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

* Update website/content/docs/commands/hcp.mdx

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

* Update website/content/docs/commands/hcp.mdx

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

* Update website/content/docs/commands/hcp.mdx

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

* Update website/content/docs/commands/hcp.mdx

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

* Update website/content/docs/commands/hcp.mdx

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

* Update website/content/docs/commands/hcp.mdx

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

* Fix docs nav data

* Improve docs sections

* Update hcp lib dependency

* Fix content formatting

* Update lib dependency

* Fix HCPtokenhelper problem

* Fix HCPtokenhelper problem

* Remove HCP env variables

* Remove hcp helper token

* Add error treatment for no valid credential source

* Update website/content/docs/commands/hcp/index.mdx

Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>

* Update website/content/docs/commands/hcp/disconnect.mdx

Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>

* Update website/content/docs/commands/hcp/connect.mdx

Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>

* Update website/content/docs/commands/hcp/disconnect.mdx

Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>

* Update website/content/docs/commands/hcp/index.mdx

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

* Update website/content/docs/commands/hcp/connect.mdx

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

* Modify hcp tests

---------

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>
Co-authored-by: Chris Capurso <1036769+ccapurso@users.noreply.github.com>
Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>
Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>
2024-01-09 15:29:30 +01:00
Christopher Swenson
52d9d43a1c
Refactor auto-auth backoff to helper package. (#24668)
I have an upcoming PR for event notifications that needs similar
exponential backoff logic, and I prefer the API and logic in the
auto-auth exponential backoff rather than that of
github.com/cenkalti/backoff/v3.

This does have a small behavior change: the auto-auth min backoff
will now be randomly reduced by up to 25% on the first call. This is
a desirable property to avoid thundering herd problems, where a bunch
of agents won't all try have the same retry timeout.
2024-01-04 10:26:41 -08:00
Violet Hynes
a649d2b9a9
VAULT-17292 CE portion of changes (#24667)
* VAULT-17292 CE portion of changes

* VAULT-17292 docs

* VAULT-17292 changelog
2024-01-04 13:01:38 -05:00
Steven Clark
ade75bcf00
Update licensing across various source files (#24672) 2024-01-04 12:59:46 -05:00
Violet Hynes
75d0581464
VAULT-8790 Ensure time.NewTicker never gets called with a negative value (#24402)
* Ensure time.NewTicker never gets called with a negative value

* Remove naughty newline

* VAULT-8790 review feedback
2024-01-03 15:34:41 -05:00
Chris Capurso
6b142b4dcc
VAULT-22552: Add MaxConnsPerHost field to Agent template_config (#24548)
* add MaxConnectionsPerHost to agent template config

* set MaxConnsPerHost in consul-template manager config

* add MaxConnectionsPerHost to agent generate-config

* fix agent generate-config tests

* doc updates

* bump consul-template to 0.36.0

* add changelog entry

* minor docs change

* fix nil pointer deref for MaxConnectionsPerHost template config

* Update template docs

Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>

---------

Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>
2024-01-03 15:06:41 -05:00
claire bontempo
2c19bbe145
Consistently refer to Key Value secrets engine as KV (#24529)
* VAULT-21427 change ui references from K/V to KV

* references in docs/

* website json data

* go command errors

* replace Key/Value with Key Value

* add changelog

* update test

* update secret list header badge

* two more test updates
2023-12-14 11:28:58 -08:00
Mattias Fjellström
e4ffe8979c
Command: token capabilities using accessor (#24479)
* Command: token capabilities using accessor

* release note

* Apply suggestions from code review

Co-authored-by: Marc Boudreau <marc.boudreau@hashicorp.com>

---------

Co-authored-by: Marc Boudreau <marc.boudreau@hashicorp.com>
2023-12-13 11:15:21 -05:00
Violet Hynes
879f9c9bfd
Fix flaky restore test (#24490) 2023-12-12 10:27:26 -05:00
Hamid Ghaf
57b6b74283
release log gate if disable-gated-logs flag is set (#24280)
* release log gate if disable-gated-logs flag is set

* CL

* Update changelog/24280.txt

Co-authored-by: Josh Black <raskchanky@gmail.com>

---------

Co-authored-by: Peter Wilson <peter.wilson@hashicorp.com>
Co-authored-by: Josh Black <raskchanky@gmail.com>
2023-12-11 08:08:48 -08:00
Victor Rodriguez
128152ee28
Update recovery mode guard to account for migrating away from Shamir (#24443)
It is not sufficient to check that function setSeal in server.go does not return
an "unwrap seal". For migrations away from a Shamir seal, NewCore constructor
sets up an unwrap seal by calling method adjustForSealMigration.

Factor out new method checkForSealMigration out of adjustForSealMigration so
that NewCore can verify that there won't be a migration when returning early due
to running in recovery mode.
2023-12-08 21:25:52 +00:00
Tom Proctor
a4180c193b
Refactor plugin catalog and plugin runtime catalog into their own package (#24403)
* Refactor plugin catalog into its own package
* Fix some unnecessarily slow tests due to accidentally running multiple plugin processes
* Clean up MakeTestPluginDir helper
* Move getBackendVersion tests to plugin catalog package
* Use corehelpers.MakeTestPlugin consistently
* Fix semgrep failure: check for nil value from logical.Storage
2023-12-07 12:36:17 +00:00
Victor Rodriguez
8a46bee768
Fix recovery mode check for seal migration configuration. (#24398)
With the introduction of the Seal High Availability feature, the presence of
multiple seals in configuration does not necessarily mean that the configuration
entails a seal migration.

Instead of checking for multiple seals, check for the presence on an "unwrap"
seal, which is only used for seal migrations.
2023-12-06 16:37:48 -05:00
Christopher Swenson
6ed8b88f5f
Switch from mitchellh/cli to hashicorp/cli (#24239)
@mitchellh suggested we fork `cli` and switch to that.

Since we primarily use the interfaces in `cli`, and the new
fork has not changed those, this is (mostly) a drop-in replacement.

A small fix will be necessary for Vault Enterprise, I believe.
2023-12-04 11:05:02 -08:00
Peter Wilson
06b9325bb9
fix -log-file so that it uses the correct name and only adds timestamps on rotation (#24297)
* fix -log-file so that it uses the correct name and only adds timestamps on rotation

* added some tests for naming/rotation

* changelog

* revert to previous way of getting created time

* remove unused stat

* comment shuffle

* Update changelog/24297.txt

Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>

* Update website/content/docs/agent-and-proxy/agent/index.mdx

Update 'agent' docs page

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

* Update website/content/docs/agent-and-proxy/proxy/index.mdx

Update 'proxy' docs page

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

* Update website/content/docs/commands/server.mdx

Update 'server' docs page

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

* fix typos

---------

Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>
Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>
2023-12-01 11:30:34 +00:00
Rachel Culpepper
638522ebac
Vault-18638: add seal reload on SIGHUP (#23571)
* reload seals on SIGHUP

* add lock in SetSeals

* move lock

* use stubmaker and change wrapper finalize call

* change finalize logic so that old seals will be finalized after new seals are configured

* add changelog

* run make fmt

* fix fmt

* fix panic when reloading seals errors out
2023-11-30 15:08:13 -06:00
Violet Hynes
ef3021f1a4
Fix bug in static secret caching where no token is present in a request to Proxy (#24287) 2023-11-29 09:35:59 -05:00
Peter Wilson
64dfff080a
Fix non-JSON log messages when using -log-format JSON (#24252)
* Fix non-JSON log messages when using -log-format JSON

Removed the call to consul-template's logging.Setup inside the created of config for the Runner. Instead we call it when we assign the logger to the Agent command.

* The elusive extra line

* Adjust the approach

* changelog

* Infer levels *with* timestamp prefix

* InferLeveslWithTimestamp required InferLevels

* Test to show -log-format and -log-file working in consul-template generated messages

* classic typo

---------

Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>
2023-11-29 12:46:18 +00:00
Scott Miller
78d756acdb
Provide a more reasonable error message for disabled Shamir seals (#24275) 2023-11-28 18:03:24 +00:00
Tom Proctor
51d99fc7cf
cli: Improve error handling for plugin commands (#24250)
* Stop supporting vault plugin info and deregister without a type argument
* Make a best-effort attempt to report whether a plugin was actually deregistered and give more descriptive errors
* Fix error message for vault plugin reload
2023-11-28 14:13:26 +00:00
Tom Proctor
030bba4e68
Support rootless plugin containers (#24236)
* Pulls in github.com/go-secure-stdlib/plugincontainer@v0.3.0 which exposes a new `Config.Rootless` option to opt in to extra container configuration options that allow establishing communication with a non-root plugin within a rootless container runtime.
* Adds a new "rootless" option for plugin runtimes, so Vault needs to be explicitly told whether the container runtime on the machine is rootless or not. It defaults to false as rootless installs are not the default.
* Updates `run_config.go` to use the new option when the plugin runtime is rootless.
* Adds new `-rootless` flag to `vault plugin runtime register`, and `rootless` API option to the register API.
* Adds rootless Docker installation to CI to support tests for the new functionality.
* Minor test refactor to minimise the number of test Vault cores that need to be made for the external plugin container tests.
* Documentation for the new rootless configuration and the new (reduced) set of restrictions for plugin containers.
* As well as adding rootless support, we've decided to drop explicit support for podman for now, but there's no barrier other than support burden to adding it back again in future so it will depend on demand.
2023-11-28 14:07:07 +00:00
Steven Clark
b7dff9777d
Allow backends to extract credentials from payloads and trigger an authentication workflow (#23924)
* wip

* Work on the tuneable allowance and some bugs

* Call handleCancellableRequest instead, which gets the audit order more correct and includes the preauth response

* Get rid of no longer needed operation

* Phew, this wasn't necessary

* Add auth error handling by the backend, and fix a bug with handleInvalidCredentials

* Cleanup req/resp naming

* Use the new form, and data

* Discovered that tokens werent really being checked because isLoginRequest returns true for the re-request into the backend, when it shouldnt

* Add a few more checks in the delegated request handler for bad inputs

 - Protect the delegated handler from bad inputs from the backend such
   as an empty accessor, a path that isn't registered as a login request
 - Add similar protections for bad auth results as we do in the normal
   login request paths. Technically not 100% needed but if somehow the
   handleCancelableRequest doesn't use the handleLoginRequest code path
   we could get into trouble in the future
 - Add delegated-auth-accessors flag to the secrets tune command and
   api-docs

* Unit tests and some small fixes

* Remove transit preauth test, rely on unit tests

* Cleanup and add a little more commentary in tests

* Fix typos, add another failure use-case which we reference a disabled auth mount

* PR Feedback

 - Use router to lookup mount instead of defining a new lookup method
 - Enforce auth table types and namespace when mount is found
 - Define a type alias for the handleInvalidCreds
 - Fix typos/grammar
 - Clean up globals in test

* Additional PR feedback

 - Add test for delegated auth handler
 - Force batch token usage
 - Add a test to validate failures if a non-batch token is used
 - Check for Data member being nil in test cases

* Update failure error message around requiring batch tokens

* Trap MFA requests

* Reword some error messages

* Add test and fixes for delegated response wrapping

* Move MFA test to dedicated mount

 - If the delegated auth tests were running in parallel, the MFA test
   case might influence the other tests, so move the MFA to a dedicated
   mount

* PR feedback: use textproto.CanonicalMIMEHeaderKey

 - Change the X-Vault-Wrap-Ttl constant to X-Vault-Wrap-TTL
   and use textproto.CanonicalMIMEHeaderKey to format it
   within the delete call.
 - This protects the code around changes of the constant typing

* PR feedback

 - Append Error to RequestDelegatedAuth
 - Force error interface impl through explicit nil var assignment on
   RequestDelegatedAuthError
 - Clean up test factory and leverage NewTestSoloCluster
 - Leverage newer maps.Clone as this is 1.16 only

---------

Co-authored-by: Scott G. Miller <smiller@hashicorp.com>
2023-11-21 14:36:49 -05:00
Scott Miller
913481fb1f
OSS fixes (#24200) 2023-11-21 10:25:01 -06:00
Steven Clark
68fbb17b9c
TestTransitImport: Generate Transit wrapping key with a longer context (#24212)
- Instead of relying on the initial call to import to generate the
   wrapping key, generate it within the test setup with a longer
   dedicated timeout.
 - This hopefully is enough of a timeout for the 32 bit nightly runner
2023-11-21 10:58:44 -05:00
Nick Cabatoff
1bf366ccdc
Use our fork of bbolt to improve freelist performance (#24010) 2023-11-21 10:08:18 -05:00
Divya Pola
117118e2bd
Add error checking when creating seal.Access object (#24181) 2023-11-17 19:28:24 +00:00
Violet Hynes
91ab8a5178
Add a sleep to give the event system time to start (#24141) 2023-11-15 10:33:27 -05:00
Violet Hynes
3e054cbd4c
VAULT-19239 Add capability to disable dynamic secret caching for Vault Proxy (#23801)
* VAULT-19239 create disable static secret caching config

* VAULT-19239 missed file

* VAULT-19239 didn't finish a log line

* VAULT-19239 adjust test to use new option

* Fix typo

Co-authored-by: Kuba Wieczorek <kuba.wieczorek@hashicorp.com>

---------

Co-authored-by: Kuba Wieczorek <kuba.wieczorek@hashicorp.com>
2023-11-15 09:11:10 -05:00
Violet Hynes
d7403d2790
VAULT-19275 Add pre-event stream static secret update mechanism (#23719)
* VAULT-19275 Add pre-event stream static secret update mechanism

* VAULT-19275 fix multierror append

* VAULT-19275 review updates
2023-11-09 13:56:29 -05:00
Violet Hynes
71f1472852
VAULT-21325 Use free ports for process manager Agent tests (#23943) 2023-11-09 09:23:42 -05:00
Hamid Ghaf
9d3617e567
Revert "Automatically track subloggers in allLoggers (#22038)" (#23986)
This reverts commit 4c8cc87794ed2d989f515cd30c1c1b953d092ef3.
2023-11-03 11:08:01 -07:00
Violet Hynes
fd2c737c51
Fix lifetime watcher user agent reporting Vault Agent for Vault Proxy requests (#23944) 2023-11-03 10:24:43 -04:00
Ellie
63ab253cb4
Add command to inspect vault snapshots (#23457)
* add vault operator inspect command

* tidy

* add tests

* add changelog

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com>

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com>

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com>

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com>

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com>

* remove test.snapshot file and create snapshot during test

* fix help text and add custom format flag

* Update changelog/23457.txt

Co-authored-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com>

* add check that kvdepth is not less than zero

* remove kvprefix from flag names

* set details flag to default to true

* remove total size, we don't use it

* fix test that referenced old flag names

* add size calculations

* return all keys if depth set to 0

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com>

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com>

* Update command/operator_raft_snapshot_inspect.go

* revert go.mod

* update comment on temp file

* update comment on closing writer

* remove temporary file, and process state.bin in memory

* return metadata like info

* remove unnused function

* remove ReadSnapshot func, and unnecessary goroutine

* remove handler, and zero values

* move defer, and return error instead of logging

* add subcommand doc

* remove -format flag

* remove comments

* change copy to copyN

* remove formatters

* remove formatters

* remove duplicate check

* fix error checks

* remove unused consts

---------

Co-authored-by: Jason O'Donnell <2160810+jasonodonnell@users.noreply.github.com>
2023-10-31 14:48:37 -05:00
Kyle Schochenmaier
ec610f273f
[docs] update docs for latest 0.26.0 release (#23890)
* update docs for latest release
* update to 0.26.1
2023-10-31 11:19:57 -07:00