Commit Graph

2645 Commits

Author SHA1 Message Date
Austin Gebauer
4016779255 defaults for token key and TTL parsing reworked, fix parse bug 2024-01-03 18:39:58 -08:00
Austin Gebauer
c6072c47ea adds read and write parsing helpers 2024-01-03 17:09:03 -08:00
Austin Gebauer
de8c8d86f8 adds field helper for plugins, subject change, token redaction stringer 2024-01-03 14:52:59 -08:00
Austin Gebauer
9df6b21727 rename role ARN field 2023-11-10 11:24:22 -08:00
Austin Gebauer
04442571e3 adds plugin identity exchange for AWS secrets engine 2023-11-07 22:03:44 -08:00
Steven Clark
a10685c521 Pin curl docker image to a specific docker version instead of latest (#23763)
- Try to avoid these build failures as our proxy does seem to have
   issues around pulling images with the 'latest' tag at times.

```
acme_test.go:206:
	Error Trace:	/home/runner/actions-runner/_work/vault-enterprise/vault-enterprise/builtin/logical/pkiext/pkiext_binary/acme_test.go:206
          	        /home/runner/actions-runner/_work/vault-enterprise/vault-enterprise/builtin/logical/pkiext/pkiext_binary/acme_test.go:75
	Error:      	Received unexpected error:
				container create failed: Error response from daemon: No such image: docker.mirror.hashicorp.services/curlimages/curl:latest
	Test:       	Test_ACME/group/caddy_http_eab
	Messages:   	could not start cURL container
```
2023-10-24 10:04:23 -04:00
Steven Clark
3623dfc227 Add support for plugins to specify binary request paths (#23729)
* wip

* more pruning

* Integrate OCSP into binary paths PoC

 - Simplify some of the changes to the router
 - Remove the binary test PKI endpoint
 - Switch OCSP to use the new binary paths backend variable

* Fix proto generation and test compilation

* Add unit test for binary request handling

---------

Co-authored-by: Scott G. Miller <smiller@hashicorp.com>
2023-10-23 17:04:42 -04:00
Hamid Ghaf
87376a1f5c Normalize error response messages when invalid credentials are provided (#23786)
* Normalize error response messages when invalid credentials are provided

* CL

* Update changelog/23786.txt

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

---------

Co-authored-by: Peter Wilson <peter.wilson@hashicorp.com>
Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>
2023-10-23 15:59:26 +00:00
davidadeleon
72d66e2813 Fix consul token revocation with namespace and admin partition specific policies (#23010)
* fix lease revocation when config token exists in one namespace but can create tokens in another

* add test

* Add similar check for admin partition

* Add admin partition test

---------

Co-authored-by: robmonte <17119716+robmonte@users.noreply.github.com>
2023-10-20 13:06:20 -05:00
modrake
eca4b4d801 Relplat 897 copywrite fixes for mutliple licenses (#23722) 2023-10-20 08:40:43 -07:00
Steven Clark
d0501db90f Forbid setting auto_rotate_period on transit managed keys (#23723)
* Forbid setting auto_rotate_period on transit managed keys

 - Prevent and guard against auto-rotating managed keys as we
   generate an invalid key version without the uuid field set.
 - Hook in the datakey generation api into managed key encryption.

* Add cl
2023-10-19 15:29:01 -04:00
kpcraig
6aabb22b7c AWS Static Secrets: Requeue credential for rotation if initial attempt fails (#23673) 2023-10-17 14:12:33 -04:00
Steven Clark
bc4be73a1c Fix Transit managed key fixes - OSS (#23676)
- This is the OSS parts of the greater enterprise PR to address some
   issues with signing and encryption within Transit using managed keys.
2023-10-16 15:52:59 -04:00
kpcraig
30f19b383f VAULT-18307: update rotation period for aws static roles on update (#23528) 2023-10-11 17:06:58 +00:00
Peter Wilson
88fb88e3db Audit: eventlogger sink node reopen on SIGHUP (#23598)
* ensure nodes are asked to reload audit files on SIGHUP

* added changelog
2023-10-11 16:46:49 +01:00
Robert
8202c7db4b auth/aws: fix panic in IAM-based login when client config doesn't exist (#23555)
Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com>
2023-10-06 14:29:28 -05:00
Robert
999111e5b3 Revert "auth/aws: fix panic in IAM-based login when client config doesn't exist (#23366)" (#23480)
This reverts commit 80e1912adb.
2023-10-03 16:01:40 -05:00
Austin Gebauer
80e1912adb auth/aws: fix panic in IAM-based login when client config doesn't exist (#23366)
* auth/aws: fix panic in IAM-based login when client config doesn't exist

* add changelog

* adds known issue for 1.15.0

* fixes up known issue with workaround

* fix link

* maintain behavior of client config not needing to exist for IAM login

* update changelog
2023-09-30 11:25:56 +09:00
Steven Clark
b0fef53184 Do not attempt to shutdown ACME thread on non-active nodes (#23293) 2023-09-26 16:32:52 -04:00
Steven Clark
dbfaa6f81a Stop processing ACME verifications when active node is stepped down (#23278)
- Do not load existing ACME challenges persisted within storage on non-active nodes. This was the main culprit of the issues, secondary nodes would load existing persisted challenges trying to resolve them but writes would fail leading to the excessive logging.
    - We now handle this by not starting the ACME background thread on non-active nodes, while also checking within the scheduling loop and breaking out. That will force a re-reading of the Closing channel that should have been called by the PKI plugin's Cleanup method.

- If a node is stepped down from being the active node while it is actively processing a verification, we could get into an infinite loop due to an ErrReadOnly error attempting to clean up a challenge entry

- Add a maximum number of retries for errors around attempting to decode,fetch challenge/authorization entries from disk. We use double the number of "normal" max attempts for these types of errors, than we would for normal ACME retry attempts to avoid collision issues. Note that these additional retry attempts are not persisted to disk and will restart on every node start

- Add a 1 second backoff to any disk related error to not immediately spin on disk/io errors for challenges.
2023-09-26 13:59:13 -04:00
vinay-gopalan
8924f9592d Remove SA Credentials from DB Connection Details on Read (#23256) 2023-09-22 10:49:46 -07:00
John-Michael Faircloth
9569b16114 secrets/db: add rotation error path test (#23182)
* secrets/db: add rotation error path test

We add a test to verify that failed rotations can successfully recover
and that they do not occur outside of a rotation window. Additionally,
we remove registering some external plugins in getCluster() that shaves
off about 5 minutes the database package tests.

* remove dead code and add test comment

* revert to original container helper after refactor
2023-09-20 14:07:17 -05:00
Violet Hynes
f943c37a83 VAULT-19237 Add mount_type to secret response (#23047)
* VAULT-19237 Add mount_type to secret response

* VAULT-19237 changelog

* VAULT-19237 make MountType generic

* VAULT-19237 clean up comment

* VAULT-19237 update changelog

* VAULT-19237 update test, remove mounttype from wrapped responses

* VAULT-19237 fix a lot of tests

* VAULT-19237 standby test
2023-09-20 09:28:52 -04:00
John-Michael Faircloth
1e76ad42ef secrets/db: add tests for static role config updates (#23153) 2023-09-19 10:12:09 -05:00
Raymond Ho
018e5675fe VAULT 18227/introduce cap ldap library (#22185) 2023-09-14 10:26:29 -07:00
Steven Clark
293e8b8ac5 Fix enterprise failure of TestCRLIssuerRemoval (#23038)
This fixes the enterprise failure of the test
 ```
  === FAIL: builtin/logical/pki TestCRLIssuerRemoval (0.00s)
     crl_test.go:1456:
         	Error Trace:	/home/runner/actions-runner/_work/vault-enterprise/vault-enterprise/builtin/logical/pki/crl_test.go:1456
         	Error:      	Received unexpected error:
         	            	Global, cross-cluster revocation queue cannot be enabled when auto rebuilding is disabled as the local cluster may not have the certificate entry!
         	Test:       	TestCRLIssuerRemoval
         	Messages:   	failed enabling unified CRLs on enterprise

 ```
2023-09-13 08:11:52 -04:00
Alexander Scheel
e2ff1f1c71 Clean up unused CRL entries when issuer is removed (#23007)
* Clean up unused CRL entries when issuer is removed

When a issuer is removed, the space utilized by its CRL was not freed,
both from the CRL config mapping issuer IDs to CRL IDs and from the
CRL storage entry. We thus implement a two step cleanup, wherein
orphaned CRL IDs are removed from the config and any remaining full
CRL entries are removed from disk.

This relates to a Consul<->Vault interop issue (#22980), wherein Consul
creates a new issuer on every leadership election, causing this config
to grow. Deleting issuers manually does not entirely solve this problem
as the config does not fully reclaim space used in this entry.

Notably, an observation that when deleting issuers, the CRL was rebuilt
on secondary clusters (due to the invalidation not caring about type of
the operation); for consistency and to clean up the unified CRLs, we
also need to run the rebuild on the active primary cluster that deleted
the issuer as well.

This approach does allow cleanup on existing impacted clusters by simply
rebuilding the CRL.

Co-authored-by: Steven Clark <steven.clark@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add test case on CRL removal

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add changelog entry

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

---------

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Co-authored-by: Steven Clark <steven.clark@hashicorp.com>
2023-09-12 20:56:47 +00:00
Peter Wilson
ae774b93d3 VAULT-18160: Audit - options and defaults (#22295)
* options for syslog

* fix bug in default value for HMACAccessor

* backend device cleanup

* socket backend options update

* options: prefix removed check, added default file mode

* fix option setting for elision

* fix test for prefix and whitespace
2023-09-11 08:41:29 +00:00
Scott Miller
7d4d8cb708 Reject supplied nonces for non-convergent encryption operations (#22852)
* Ignore nonces when encrypting without convergence or with convergence versions > 1

* Honor nonce use warning in non-FIPS modes

* Revert "Honor nonce use warning in non-FIPS modes"

This reverts commit 2aee3dbdc11c4e333ecb20503539c7993b24ee57.

* Add a test func that removes a nonce when not needed

* err out rather than ignore the nonce

* Alter unit test to cover, also cover convergent version 3

* More unit test work

* Fix test 14

* changelog

* tests not already in a nonce present path

* Update unit test to not assume warning when nonce provided incorrectly

* remove unused test field

* Fix auto-squash events experiments

When #22835 was merged, it was auto-squashed, so the `experiments`
import was removed, but the test still referenced it.

This removes the (now unnecessary) experiment from the test.

* Allow nonces for managed keys, because we have no way of knowing if the backing cipher/mode needs one

---------

Co-authored-by: Christopher Swenson <christopher.swenson@hashicorp.com>
2023-09-08 08:07:33 -05:00
John-Michael Faircloth
16f805419f fix rotation_window bug in error path (#22699) 2023-08-31 15:45:01 -05:00
John-Michael Faircloth
aa05ba6105 adv ttl mgmt: define schedule interface (#22590) 2023-08-28 13:14:38 -07:00
Thomas Schweizer-Bolzonello
958eb96bab Fix typo OSCP -> OCSP (#22586) 2023-08-28 18:39:01 +00:00
Max Bowsher
479519e6df Fix erroneous OpenAPI operation IDs (#22579)
The recent additions to the transit secret engine have created two new
endpoints which both have the incorrect (and duplicate) operation ID of
just `"update"`.

Amend to unique meaningful values.
2023-08-28 09:11:16 -04:00
Milena Zlaticanin
2d0d5c79ed Add the ability to set seconds in cron schedule for testing purposes (#22531)
* add rotation_schedule field to db backend

* add cron schedule field

* use priority queue with scheduled rotation types

* allow marshalling of cron schedule type

* return warning on use of mutually exclusive fields

* handle mutual exclusion of rotation fields (#22306)

* handle mutual exclusion of rotation fields

* fix import

* adv ttl mgmt: add rotation_window field (#22303)

* adv ttl mgmt: add rotation_window field

* do some rotation_window validation and add unit tests

* adv ttl mgmt: Ensure initialization sets appropriate rotation schedule (#22341)

* general cleanup and refactor rotation type checks

* make NextRotationTime account for the rotation type

* add comments

* add unit tests to handle mutual exclusion (#22352)

* add unit tests to handle mutual exclusion

* revert rotation_test.go and add missing test case to path_roles_test.go

* adv ttl mgmt: add tests for init queue (#22376)

* Vault 18908/handle manual rotation (#22389)

* support manual rotation for schedule based roles

* update description and naming

* adv ttl mgmt: consider rotation window (#22448)

* consider rotation window

ensure rotations only occur within a rotation window for schedule-based
rotations

* use helper method to set priority in rotateCredential

* fix bug with priority check

* remove test for now

* add and remove comments

* add unit tests for manual rotation (#22453)

* adv ttl mgmt: add tests for rotation_window

* adv ttl mgmt: refactor window tests (#22472)

* Handle GET static-creds endpoint (#22476)

* update read static-creds endpoint to include correct resp data

* return rotation_window if set

* update

* add changelog

* add unit test for static-creds read endpoint (#22505)

* Add the ability to set seconds in cron schedule for testing purposes

* update test so we don't use global var

* update with suggestions

---------

Co-authored-by: JM Faircloth <jmfaircloth@hashicorp.com>
Co-authored-by: John-Michael Faircloth <fairclothjm@users.noreply.github.com>
2023-08-25 09:42:15 -07:00
John-Michael Faircloth
83f3e391c2 secrets/database: advanced TTL management for static roles (#22484)
* add rotation_schedule field to db backend

* add cron schedule field

* use priority queue with scheduled rotation types

* allow marshalling of cron schedule type

* return warning on use of mutually exclusive fields

* handle mutual exclusion of rotation fields (#22306)

* handle mutual exclusion of rotation fields

* fix import

* adv ttl mgmt: add rotation_window field (#22303)

* adv ttl mgmt: add rotation_window field

* do some rotation_window validation and add unit tests

* adv ttl mgmt: Ensure initialization sets appropriate rotation schedule (#22341)

* general cleanup and refactor rotation type checks

* make NextRotationTime account for the rotation type

* add comments

* add unit tests to handle mutual exclusion (#22352)

* add unit tests to handle mutual exclusion

* revert rotation_test.go and add missing test case to path_roles_test.go

* adv ttl mgmt: add tests for init queue (#22376)

* Vault 18908/handle manual rotation (#22389)

* support manual rotation for schedule based roles

* update description and naming

* adv ttl mgmt: consider rotation window (#22448)

* consider rotation window

ensure rotations only occur within a rotation window for schedule-based
rotations

* use helper method to set priority in rotateCredential

* fix bug with priority check

* remove test for now

* add and remove comments

* add unit tests for manual rotation (#22453)

* adv ttl mgmt: add tests for rotation_window

* adv ttl mgmt: refactor window tests (#22472)

* Handle GET static-creds endpoint (#22476)

* update read static-creds endpoint to include correct resp data

* return rotation_window if set

* update

* add changelog

* add unit test for static-creds read endpoint (#22505)

---------

Co-authored-by: Milena Zlaticanin <60530402+Zlaticanin@users.noreply.github.com>
2023-08-24 16:45:07 -05:00
Alexander Scheel
a2a4831754 Minor improvements to transit & csrs (#22494)
* Remove note

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Remove duplicate curve check

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Remove CreateOperation from new Transit X.509 endpoints

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add test to validate key matching works

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

---------

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
2023-08-22 10:51:37 -04:00
Gabriel Santos
1996377b4f Transit backend: Create CSR's from keys in transit and import certificate chains (#21081)
* setup initial boilerplate code for sign csr endpoint

* add function to sign csr

* working version of sign csr endpoint

* improving errors for csr create and sign endpoint

* initial implementation for import leaf certificate endpoint

* check if more than one certificate was provided in the ceritificate chain

* improve validate cert public key matches transit key

* convert provided cert chain from PEM to DER so it can be parsed by
x509.ParseCertificates and fixing other bugs

* fix creation of csr from csrTemplate

* add missing persist of certificate chain after validations in set-certificate endpoint

* allow exporting a certificate-chain

* move function declaration to end of page

* improving variable and function names, removing comments

* fix certificate chain parsing - work in progress

* test for signCsr endpoint

* use Operations instead of Callbacks in framework.Path

* setup test for set-certificate endpoint

fix problems with sign-csr endpoint returning base64

* finish set-certificate endpoint test

* use public key KeyEntry fields instead of retrieving public key from private

* improve error message and make better distinction between client and server error

also moved check of key types before checking if key match to endpoint handler

* check if private key has been imported for key version selected when signing a csr

* improve errors

* add endpoint description and synopsis

* fix functions calls in backend as function names changed

* improve import cert chain test

* trim whitespaces on export certificate chain

* changelog

* pass context from handler function to policy Persist

* make fmt run

* fix: assign returned error from PersistCertificateChain to err so it can be evaluated

* additional validations and improvements to parseCertificateChain function

* add validation to check if there is only one certificate in the certificate chain and it is in the first position

* import cert chain test: move creation of cluster to exported test function

* move check of end-cert pub key algorithm and key transit algorithm match into a separate function

* test export certificate chain

* Update sdk/helper/keysutil/policy.go

Co-authored-by: Alexander Scheel <alexander.m.scheel@gmail.com>

* fix validateLeafCertPosition

* reject certificate actions on policies that allow key derivation and remove derived checks

* return UserError from CreateCSR SDK function as 400 in transit API handler

* add derived check for ED5519 keys on CreateCSR SDK func

* remove unecessary calls of x509.CreateCertificateRequest

* move validate key type match back into SDK ValidateLeafCertMatch function

* add additional validations (ValidateLeafCertKeyMatch, etc) in SDK PersistCertificateChain function

* remove uncessary call of ValidateLeafCertKeyMatch in parseImportCertChainWrite

* store certificate chain as a [][]byte instead of []*x509.Certificate

* include persisted ca chain in import cert-chain response

* remove NOTE comment

* allow exporting cert-chain even if exportable is set as false

* remove NOTE comment

* add certifcate chain to formatKeyPublic if present

also added an additional check to validate if field is added when
certchain is present

---------

Co-authored-by: Alexander Scheel <alexander.m.scheel@gmail.com>
2023-08-22 08:24:56 -04:00
Michael Dempsey
d6b7e5bfa1 Add support for signed GET requests for aws authentication (#10961)
* Support GET requests for aws-iam

This is required to support presigned requests from aws-sdk-go-v2

* Add GET method tests for aws-iam auth login path

* Update Website Documenation

* Validate GET action even if iam-server header is not set

* Combine URL checks

* Add const amzSignedHeaders to aws credential builtin

* Add test for multiple GET request actions

* Add Changelog Entry

---------

Co-authored-by: Max Coulombe <109547106+maxcoulombe@users.noreply.github.com>
2023-08-15 15:40:12 -04:00
hashicorp-copywrite[bot]
0b12cdcfd1 [COMPLIANCE] License changes (#22290)
* Adding explicit MPL license for sub-package.

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Adding explicit MPL license for sub-package.

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Updating the license from MPL to Business Source License.

Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl.

* add missing license headers

* Update copyright file headers to BUS-1.1

* Fix test that expected exact offset on hcl file

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Sarah Thompson <sthompson@hashicorp.com>
Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
2023-08-10 18:14:03 -07:00
Steven Clark
8f646d52be Refactor sign-intermediate API response (#22269)
* Refactor sign-intermediate API response

 - Allow the sign-intermediate response handling code to be shared
   across different API calls.

* Add missing cieps.go
2023-08-10 09:58:07 -04:00
Marc Boudreau
b07eff0998 VAULT-18934: Record individual metrics for each Auditing Event Pipeline (#22266)
* add sink wrapper to take telemetry measures

* make use of sinkwrapper
2023-08-10 09:49:55 -04:00
Peter Wilson
32b6a5c840 VAULT-18157: Audit events: Log Test Message (#22263)
* manually crank the nodes to log a test message (if we have them configured)
* try to extract the duplicated manual processing of nodes
2023-08-09 21:04:31 +01:00
Austin Gebauer
a70aaf24c0 secrets/db: improves error logs for static role rotation (#22253)
* secrets/db: improves error logs for static role rotation

* use logger.With to add incremental context

* adds changelog
2023-08-08 16:28:31 -07:00
Steven Clark
64460dd58b Refactor logic on applying leaf_not_after_behavior (#22230)
- Allow us to call and apply an issuer's leaf_not_after_behavior
   to a leaf certificate from various locations.
2023-08-08 13:39:54 +00:00
Steven Clark
8a174b05b0 Add timeouts to ACME test contexts (#22205)
- The Golang ACME library will retry on failures until the passed in
   context times out. So if a test is broken it will never end until
   the context expires.
 - The timeouts are rather large to avoid some issues with slow CI
   runners, that have already triggered on a nightly 32 bit run
2023-08-04 11:09:37 -04:00
Steven Clark
3a46df2077 Use Hashicorp docker proxy for CI docker images (#22195)
* Use Hashicorp docker proxy for CI docker images

* Use library/consul as the mirror path instead of hashicorp/consul

 - Looks like the older 1.4.4 image was not published within the
   hashicorp/consul space, only newer images are.
 - Switch to library/consul which seems to have both versions
2023-08-03 13:42:20 -04:00
Steven Clark
66052d5431 Refactor ACME for enterprise CIEPS integration (#22188) 2023-08-03 11:24:46 -04:00
Kushneryk Pavel
64f92b40fc bug(20562): allowed_domains are compared case-sensitive if they use g… (#22126)
* bug(20562): allowed_domains are compared case-sensitive if they use glob patterns

* bug(20562): review fixes
2023-08-02 11:09:10 -04:00
Peter Wilson
30114d0038 Moved HeaderFormatter to an Option for NewEntryFormatter, updated tests (#22116) 2023-07-28 17:07:20 +01:00
Raymond Ho
4f7a8fb494 AWS auth login with multi region STS support (#21960) 2023-07-28 08:42:22 -07:00