46 Commits

Author SHA1 Message Date
Vault Automation
2ef4c50221
Add audit log entries for new token type (#12747) (#12908)
* Add audit log entries for enterprise JWT token fields



* Reduce enterprise token field comment detail

- simplify enterprise token comments in sdk/logical/request.go
- remove verbose wording about issuer/audience/authorization semantics



* Fix TestAudit_JWT_DelegationToken permission denied error

The test was failing with 'permission denied' when using a delegation token
(JWT with act claim) to access cubbyhole. The root causes were:

1. RAR (Rich Authorization Request) check: The JWT contained
   'authorization_details' constraints that only allowed access to
   'secret/data/users/alice' and 'secret/data/config/general', but the
   test was attempting to access 'cubbyhole/test'. The RAR check in
   PerformRARCheck() was correctly denying this mismatch.

2. Missing entity policies for actor ACL: For delegation tokens, the
   actor's ACL is built solely from entity identity policies (not token
   policies like 'default'). Without explicit policies on the actor
   entity, the delegation ACL intersection check would fail.

Fixes:
- Removed 'authorization_details' from the test JWT since the test is
  about verifying audit log entries for delegation tokens, not RAR
  constraints
- Added 'default' policy to both subject and actor entities to ensure
  both ACLs allow cubbyhole access for the delegation token intersection
- Updated test assertions to match the simplified JWT (removed
  authorization_details verification)



* Use require.NoError instead of t.Fatalf for error check



* Add explicit checks for auth field presence before type assertion

Adds separate checks to verify the 'auth' and 'metadata' fields exist in
the map before attempting type assertion, preventing potential panics
and improving test clarity.



* test: tighten request metadata merge assertions



* test: simplify enterprise metadata assertions



* test: split enterprise metadata merge coverage



* style: apply gofumpt to entry formatter tests



* test: add godoc for enterprise token metadata test



---------

Co-authored-by: Bianca <48203644+biazmoreira@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-11 19:21:10 +01:00
Vault Automation
f5dbe55f55
VAULT-42657: Merge feature branch for OAuth and Agent Registry into main (#12587) (#12754)
* feat(identity): accept oauth tokens

type: draft

* feat(identity): make basic token lookup op work

type: draft

* fix(identity): failing tests

type: draft

* feat(identity): add new tests + handle renew & revoke

type: draft

* feat(identity): clean up and tests

type: draft

* feat(identity)(Accept OAuth JWT tokens): Add more tests

* feat(identity)(Accept OAuth JWT tokens): Test updates

* feat(identity)(Accept OAuth JWT tokens): Revert go version changes

* feat(identity)(Accept OAuth JWT tokens): add missing godoc for tests

* feat(identity)(Accept OAuth JWT tokens): fix tests

* feat(identity)(Accept OAuth JWT tokens): fix more CI issues

* [POC] Accept and Validate External OAuth Token for Agent Identity (#10991)

* feat(identity): accept oauth tokens

type: draft

* feat(identity): make basic token lookup op work

type: draft

* fix(identity): failing tests

type: draft

* feat(identity): add new tests + handle renew & revoke

type: draft

* feat(identity): clean up and tests

type: draft

* feat(identity)(Accept OAuth JWT tokens): Add more tests

* feat(identity)(Accept OAuth JWT tokens): Test updates

* feat(identity)(Accept OAuth JWT tokens): Revert go version changes

* feat(identity)(Accept OAuth JWT tokens): add missing godoc for tests

* feat(identity)(Accept OAuth JWT tokens): fix tests

* feat(identity)(Accept OAuth JWT tokens): fix more CI issues

* Add JWT token tidy cleanup functionality

* Refactor JWT tidy tests to use retryUntil instead of time.Sleep

* feat(identity)(Accept OAuth JWT tokens): fix leaky lease



* feat(identity)(Accept OAuth JWT tokens): fix leaky lease II and add claims to TE



* Add TestLogicalWithJwtAndSCIM e2e test

* feat(identity)(Accept OAuth JWT tokens): add more tests



* feat(identity)(Accept OAuth JWT tokens): change email



* feat(identity)(Accept OAuth JWT tokens): e2e test for scim



* Accept and validate RAR (#11005)



* fix(identity)(Accept OAuth JWT tokens): add missing headers



---------




* wip

* wip

* wip

* feat(identity): auth with delegation jwts



* feat(identity): optimize jwks fetching



* wip

* add lookup by entity-id

* feat(identity): optimize jwks fetching



* feat(identity): optimize jwks fetching and refactoring



* feat(identity): fix breaking tests



* feat(identity): accept oauth tokens

type: draft

* feat(identity): make basic token lookup op work

type: draft

* fix(identity): failing tests

type: draft

* feat(identity): add new tests + handle renew & revoke

type: draft

* feat(identity): clean up and tests

type: draft

* feat(identity)(Accept OAuth JWT tokens): Add more tests

* feat(identity)(Accept OAuth JWT tokens): Test updates

* feat(identity)(Accept OAuth JWT tokens): Revert go version changes

* feat(identity)(Accept OAuth JWT tokens): add missing godoc for tests

* feat(identity)(Accept OAuth JWT tokens): fix tests

* feat(identity)(Accept OAuth JWT tokens): fix more CI issues

* [POC] Accept and Validate External OAuth Token for Agent Identity (#10991)

* feat(identity): accept oauth tokens

type: draft

* feat(identity): make basic token lookup op work

type: draft

* fix(identity): failing tests

type: draft

* feat(identity): add new tests + handle renew & revoke

type: draft

* feat(identity): clean up and tests

type: draft

* feat(identity)(Accept OAuth JWT tokens): Add more tests

* feat(identity)(Accept OAuth JWT tokens): Test updates

* feat(identity)(Accept OAuth JWT tokens): Revert go version changes

* feat(identity)(Accept OAuth JWT tokens): add missing godoc for tests

* feat(identity)(Accept OAuth JWT tokens): fix tests

* feat(identity)(Accept OAuth JWT tokens): fix more CI issues

* Add JWT token tidy cleanup functionality

* Refactor JWT tidy tests to use retryUntil instead of time.Sleep

* feat(identity)(Accept OAuth JWT tokens): fix leaky lease



* feat(identity)(Accept OAuth JWT tokens): fix leaky lease II and add claims to TE



* Add TestLogicalWithJwtAndSCIM e2e test

* feat(identity)(Accept OAuth JWT tokens): add more tests



* feat(identity)(Accept OAuth JWT tokens): change email



* feat(identity)(Accept OAuth JWT tokens): e2e test for scim



* Accept and validate RAR (#11005)



* fix(identity)(Accept OAuth JWT tokens): add missing headers



---------




* feat(identity): auth with delegation jwts



* feat(identity): optimize jwks fetching



* wip

* wip

* wip

* wip

* add lookup by entity-id

* feat(identity): optimize jwks fetching



* feat(identity): optimize jwks fetching and refactoring



* feat(identity): fix breaking tests



* VAULT-42642 Fix feature branch tests, some CE -> Ent moving (#12417)

* VAULT-42642 Fix feathre branch tests, some CE -> Ent moving

* VAULT-42642 fix last test?

* skip test

* proto

* more test fixes

* buf format

* Fix createVaultEntityForUser signature (#12439)

* VAULT-42533 Agent Registry: enforce entity invariants, miscellaneous improvements (#12399)

* VAULT-42533 enforce entity invariants, miscellaneous improvements

* typos

* Improve path handling for rar + add tests (#11934)

* Moving stuff around for CE

* fmt

* backend

* more CE changes

* more fixes

* further fixes

* rework clone

* VAULT-42621 Move JWT tests (and some standalone functionality) to enterprise files (#12460)

* VAULT-42621 Move JWT tests (and some standalone functionality) to enterprise files

* logical

* skip failing tests

* more skips

* missed tests

* one more

* VAULT-42619 Refactor token_ent and surrounding files to move logic into enterprise (#12473)

* VAULT-42619 Refactor token_ent and surrounding files to move logic into enterprise

* test fixes

* feedback

* VAULT-42631 Rename ISJWT to IsEnterpriseToken, some refactoring (#12509)

* VAULT-42631 Rename ISJWT to IsEnterpriseToken, some refactoring

* godocs

* VAULT-42779 refactor JWT parts of acl.go to enterprise files (#12512)

* VAULT-42630 move token tidy for JWT to ent files (#12534)

* VAULT-42818 rename jwtjti in request struct (#12539)

* VAULT-42633 CE-ify request handling and flow around validateJwtAndFetchEntity (#12541)

* VAULT-42633 CE-ify request handling

* Copyright headers

* VAULT-42633 Move IsJWT back to CE code, add explanations (#12576)

* VAULT-42633 CE-ify request handling

* Copyright headers

* VAULT-42633 Move IsJWT back to CE code, add explanations

* VAULT-42870 Move jwtAuthManager to enterprise (#12586)

* VAULT-42796 Move config to enterprise files (#12604)

* VAULT-42796 Move config to enterprise files

* more build failures

* fix test util

* two more compilatin things

* VAULT42796 - fix missing return (#12617)

* VAULT-42796 Move config to enterprise files

* more build failures

* fix test util

* two more compilatin things

* VAUlt-42796 fix test

* Fix linting for rar_ent (#12618)

* VAULT-42796 Move config to enterprise files

* more build failures

* fix test util

* two more compilatin things

* VAUlt-42796 fix test

* Fix linter for rar code

* fix authresults

* typo

* return error

* fix method signature

---------

Signed-off-by: Arnab Chatterjee <arnab.chatterjee@hashicorp.com>
Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>
Co-authored-by: Arnab Chatterjee <arnab.chatterjee@hashicorp.com>
Co-authored-by: Arnab Chatterjee <arnabkaycee@gmail.com>
Co-authored-by: Bianca <48203644+biazmoreira@users.noreply.github.com>
Co-authored-by: davidadeleon <ddeleon@hashicorp.com>
Co-authored-by: Bianca Moreira <bianca.moreira@hashicorp.com>
2026-03-05 10:25:59 -05:00
Vault Automation
9839d40b10
Backport rotationMgr: enable RM to send rotation information to plugins on registration/rotation operations into ce/main (#12308)
* rotation-manager: enable RM to send rotation information to plugins on registration/rotation operations (#11810)

* initial commit for sending NVR to plugins

* add changelog

* add NVR to plugin fields, add RotationInfo to GRPC request handler

* fix tests

* ensure consistent formats on times and ttls

* add translation to allow grpc data transfer

* fix tests and rename fields

* fix missed field renames in tests

* make all methods net-new for backwards compatibility

* update mock plugin and add oss stub back

* remove method with no usages

* Address wrapper comments

* Rebuild proto

* Nil check around SetRotationInfo, return n/a for no last_vault_rotation

* Fix error to match other instances

* Update fields.go

* Return nil if unset for next/last vault rotation times

---------

Co-authored-by: robmonte <17119716+robmonte@users.noreply.github.com>

* Fix return type in stub method

---------

Co-authored-by: vinay-gopalan <86625824+vinay-gopalan@users.noreply.github.com>
Co-authored-by: robmonte <17119716+robmonte@users.noreply.github.com>
2026-02-12 18:25:47 -06:00
Vault Automation
0c6c13dd38
license: update headers to IBM Corp. (#10229) (#10233)
* license: update headers to IBM Corp.
* `make proto`
* update offset because source file changed

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-21 15:20:20 -06:00
miagilepner
bcd584af20
VAULT-37630: CE changes for recover as a copy policy handling (#31472)
* CE changes for recover as a copy policy

* make proto
2025-08-12 10:29:22 +02:00
miagilepner
1c37b94d65
VAULT-35079: Scaffolding for recover operations on backends (#30556)
* allow snapshot read, recover operation, snapshot ID in request

* lint and add comment
2025-05-09 11:48:20 +01:00
vinay-gopalan
838a38443f
Update Rotation Manager OSS Stubs and SDK methods (#29401) 2025-01-28 14:24:44 -06:00
vinay-gopalan
27bd3e9535
Add SDK helpers and Core stubs for plugins to communicate with Enterprise Rotation Manager (#29273)
Co-authored-by: Robert <17119716+robmonte@users.noreply.github.com>
Co-authored-by: John-Michael Faircloth <fairclothjm@users.noreply.github.com>
2025-01-07 22:22:45 +00:00
Mike Palmiotto
080780b497
Add a TraceID for forwarded request tracing (#26939) 2024-05-10 17:04:01 +00:00
Mike Palmiotto
c5fac98d2d
AOP: Force reject header (enterprise) (#26702)
This PR introduces the CE plumbing for a new HTTP header, called
X-Vault-AOP-Force-Reject, which will force any associated request to
reject storage writes as if Vault were overloaded.

This flag is intended to test end-to-end functionality of write
rejection in Vault. This is specifically useful for testing 503 -
Service Unavailable HTTP response codes during load shedding.
2024-05-01 14:11:24 -04:00
Christopher Swenson
961bf20bdb
Use enumer to generate String() methods for most enums (#25705)
We have many hand-written String() methods (and similar) for enums.
These require more maintenance and are more error-prone than using
automatically generated methods. In addition, the auto-generated
versions can be more efficient.

Here, we switch to using https://github.com/loggerhead/enumer, itself
a fork of https://github.com/diegostamigni/enumer, no longer maintained,
and a fork of the mostly standard tool
https://pkg.go.dev/golang.org/x/tools/cmd/stringer.
We use this fork of enumer for Go 1.20+ compatibility and because
we require the `-transform` flag to be able to generate
constants that match our current code base.

Some enums were not targeted for this change:
2024-04-17 11:14:14 -07:00
Marc Boudreau
c37978395f
fix VAULT-24372 (#25639)
* fix VAULT-24372

* use redaction settings in context to redact values in sys/leader

* add tests to check redaction in GetLeaderStatus and GetSealStatus

* add ENT badge to sys/config/ui/custom-messages api-docs page in ToC

* remove unrelated change to website ToC
2024-02-28 14:34:55 -05:00
Mike Palmiotto
b54ac98a0b
Move Request Limiter to enterprise (#25615) 2024-02-27 16:24:06 -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
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
43be9fc18a
Request Limiter (#25093)
This commit introduces two new adaptive concurrency limiters in Vault,
which should handle overloading of the server during periods of
untenable request rate. The limiter adjusts the number of allowable
in-flight requests based on latency measurements performed across the
request duration. This approach allows us to reject entire requests
prior to doing any work and prevents clients from exceeding server
capacity.

The limiters intentionally target two separate vectors that have been
proven to lead to server over-utilization.

- Back pressure from the storage backend, resulting in bufferbloat in
  the WAL system. (enterprise)
- Back pressure from CPU over-utilization via PKI issue requests
  (specifically for RSA keys), resulting in failed heartbeats.

Storage constraints can be accounted for by limiting logical requests
according to their http.Method. We only limit requests with write-based
methods, since these will result in storage Puts and exhibit the
aforementioned bufferbloat.

CPU constraints are accounted for using the same underlying library and
technique; however, they require special treatment. The maximum number
of concurrent pki/issue requests found in testing (again, specifically
for RSA keys) is far lower than the minimum tolerable write request
rate. Without separate limiting, we would artificially impose limits on
tolerable request rates for non-PKI requests. To specifically target PKI
issue requests, we add a new PathsSpecial field, called limited,
allowing backends to specify a list of paths which should get
special-case request limiting.

For the sake of code cleanliness and future extensibility, we introduce
the concept of a LimiterRegistry. The registry proposed in this PR has
two entries, corresponding with the two vectors above. Each Limiter
entry has its own corresponding maximum and minimum concurrency,
allowing them to react to latency deviation independently and handle
high volumes of requests to targeted bottlenecks (CPU and storage).

In both cases, utilization will be effectively throttled before Vault
reaches any degraded state. The resulting 503 - Service Unavailable is a
retryable HTTP response code, which can be handled to gracefully retry
and eventually succeed. Clients should handle this by retrying with
jitter and exponential backoff. This is done within Vault's API, using
the go-retryablehttp library.

Limiter testing was performed via benchmarks of mixed workloads and
across a deployment of agent pods with great success.
2024-01-26 14:26:21 -05:00
Peter Wilson
a928c372b8
Audit: LogInput.Request Cloning update (#24885)
* use already existing Clone method for Request (and add extra fields that need manually setting)
2024-01-16 16:57:21 +00:00
divyaac
6e020e38e0
Add_Chroot_Namespace_In_Response (#24355) 2023-12-04 14:51:44 -08:00
Hamid Ghaf
aeb817dfba
Buffer body read up to MaxRequestSize (#24354) 2023-12-04 13:22:22 -08: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
Marc Boudreau
1ebbf449b4
Improve Robustness of Custom Context Values Types (#23697) 2023-10-18 09:30:00 -04:00
Marc Boudreau
4e22153987
VAULT-19869: Use Custom Types for Context Keys (#23649)
* create custom type for disable-replication-status-endpoints context key
make use of custom context key type in middleware function

* clean up code to remove various compiler warnings
unnecessary return statement
if condition that is always true
fix use of deprecated ioutil.NopCloser
empty if block

* remove unused unexported function

* clean up code
remove unnecessary nil check around a range expression

* clean up code
removed redundant return statement

* use http.StatusTemporaryRedirect constant instead of literal integer

* create custom type for context key for max_request_size parameter

* create custom type for context key for original request path
2023-10-13 14:04:26 -04:00
Ellie
cccfdb088f
reduce calls to DetermineRoleFromLoginRequest from 3 to 1 for aws auth method (#22583)
* reduce calls to DetermineRoleFromLoginRequest from 3 to 1 for aws auth method

* change ordering of LoginCreateToken args

* replace another determineRoleFromLoginRequest function with role from context

* add changelog

* Check for role in context if not there make call to DeteremineRoleFromLoginRequest

* move context role check below nanmespace check

* Update changelog/22583.txt

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

* revert signature to same order

* make sure resp is last argument

* retrieve role from context closer to where role variable is needed

* remove failsafe for role in mfa login

* Update changelog/22583.txt

---------

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>
2023-08-28 16:01:07 -05:00
Peter Wilson
4b0d85e3bf
VAULT-11595: Augment forwarded requests with host:port info (from/to nodes) (Enterprise) (#20733)
* Allow audit entries to contain forwarded from host info
* adjust logical/request and audit format to use bool instead of string for 'to' host
2023-05-24 13:57:45 +01:00
Peter Wilson
ee3847d954
Revert "Allow audit entries may contain forwarded to/from host info (#20689)" (#20732)
This reverts commit 732dda34e726859fbb24ea51a87f3a1772bf9b7a.
2023-05-24 09:44:57 +01:00
Peter Wilson
732dda34e7
Allow audit entries may contain forwarded to/from host info (#20689) 2023-05-22 20:17:20 +01:00
Thy Ton
0e9b3b061a
feat: add plugin metadata to audit logging (#19814) 2023-04-06 00:41:07 -07:00
Alexander Scheel
38fc3e79f2
Add support for HEAD operations (#19520)
* Add header operation to sdk/logical

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

* Add support for routing HEAD operations

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>
2023-03-21 18:37:17 -04:00
Hamid Ghaf
e55c18ed12
adding copyright header (#19555)
* adding copyright header

* fix fmt and a test
2023-03-15 09:00:52 -07:00
Josh Black
03d2be4cb9
update gofumpt to 0.3.1 and reformat the repo (#17055)
* update gofumpt to 0.3.1 and reformat the repo

* output the version of the formatter we're using
2022-09-07 17:31:20 -07:00
Violet Hynes
70f19e2298
Start of implementation of the plumbing for role resolution logic on auth mounts (#16049)
* VAULT-6612 Initial scaffolding for role determination

* VAULT-6612 Simplify code

* Fix fmt error that somehow happened

* VAULT-6612 Refactor resolve role response
2022-06-21 09:31:36 -04:00
Hridoy Roy
27f15edd9f
SSCT Tokens Feature [OSS] (#14109)
* port SSCT OSS

* port header hmac key to ent and generate token proto without make command

* remove extra nil check in request handling

* add changelog

* add comment to router.go

* change test var to use length constants

* remove local index is 0 check and extra defer which can be removed after use of ExternalID
2022-02-17 11:43:07 -08:00
Josh Black
b17e3256dd
reformat using 'make fmt' (#13794) 2022-01-27 10:06:34 -08:00
hghaf099
13b8306575
VAULT-1564 report in-flight requests (#13024)
* VAULT-1564 report in-flight requests

* adding a changelog

* Changing some variable names and fixing comments

* minor style change

* adding unauthenticated support for in-flight-req

* adding documentation for the listener.profiling stanza

* adding an atomic counter for the inflight requests
addressing comments

* addressing comments

* logging completed requests

* fixing a test

* providing log_requests_info as a config option to determine at which level requests should be logged

* removing a member and a method from the StatusHeaderResponseWriter struct

* adding api docks

* revert changes in NewHTTPResponseWriter

* Fix logging invalid log_requests_info value

* Addressing comments

* Fixing a test

* use an tomic value for logRequestsInfo, and moving the CreateClientID function to Core

* fixing go.sum

* minor refactoring

* protecting InFlightRequests from data race

* another try on fixing a data race

* another try to fix a data race

* addressing comments

* fixing couple of tests

* changing log_requests_info to log_requests_level

* minor style change

* fixing a test

* removing the lock in InFlightRequests

* use single-argument form for interface assertion

* adding doc for the new configuration paramter

* adding the new doc to the nav data file

* minor fix
2021-12-08 17:34:42 -05:00
hghaf099
258193c0eb
Unify HTTPResponseWriter and StatusHeaderResponseWriter (#13200)
* Unify NewHTTPResponseWriter ant NewStatusHeaderResponseWriter to fix ResponseWriter issues

* adding changelog

* removing unnecessary function from the WrappingResponseWriter interface

* changing logical requests responseWriter type

* reverting change to HTTPResponseWriter
2021-11-23 14:30:25 -05:00
Hridoy Roy
5dc90d8081
fix adding clientID to request in audit log (#12919)
* fix adding clientID to request in audit log

* fix boolean statement

* use standard encoding for client ID instead of urlEncoding

* change encoding in tests

* add in client counts to request handling

* remove redundant client ID generation in request handling

* directly add clientID to req after handling token usage
2021-10-26 09:02:13 -07:00
Hridoy Roy
db584437b1
Port: add client ID to TWEs in activity log [vault-3136] (#12820)
* port for tracking twes as clients

* comment clean up

* changelog

* change changelog entry phrasing
2021-10-14 09:10:59 -07:00
Chris Capurso
6f65a4addc
Add HTTP PATCH support to KV (#12687)
* handle HTTP PATCH requests as logical.PatchOperation

* update go.mod, go.sum

* a nil response for logical.PatchOperation should result in 404

* respond with 415 for incorrect MIME type in PATCH Content-Type header

* add abstraction to handle PatchOperation requests

* add ACLs for patch

* Adding JSON Merge support to the API client

* add HTTP PATCH tests to check high level response logic

* add permission-based 'kv patch' tests in prep to add HTTP PATCH

* adding more 'kv patch' CLI command tests

* fix TestHandler_Patch_NotFound

* Fix TestKvPatchCommand_StdinValue

* add audit log test for HTTP PATCH

* patch CLI changes

* add patch CLI tests

* change JSONMergePatch func to accept a ctx

* fix TestKVPatchCommand_RWMethodNotExists and TestKVPatchCommand_RWMethodSucceeds to specify -method flag

* go fmt

* add a test to verify patching works by default with the root token

* add changelog entry

* get vault-plugin-secrets-kv@add-patch-support

* PR feedback

* reorder some imports; go fmt

* add doc comment for HandlePatchOperation

* add json-patch@v5.5.0 to go.mod

* remove unnecessary cancelFunc for WriteBytes

* remove default for -method

* use stable version of json-patch; go mod tidy

* more PR feedback

* temp go get vault-plugin-secrets-kv@master until official release

Co-authored-by: Josh Black <raskchanky@users.noreply.github.com>
2021-10-13 15:24:31 -04:00
Nick Cabatoff
7679223da6
Reorganize request handling code so that we don't touch storage until we have the stateLock. (#11835) 2021-06-11 13:18:16 -04:00
Nick Cabatoff
22b486b651
OSS parts of the new client controlled consistency feature (#10974) 2021-02-24 06:58:10 -05:00
Rodrigo D. L
faf2958cde
Adding a Clone() function to the request hanlder to be used when theres a need to modify the current request before saving it (#9499) 2020-07-16 09:53:46 -04:00
Michel Vocks
7c7a769320
Fix outdated comment about logical request path (#8653) 2020-04-02 08:53:16 +02:00
Calvin Leung Huang
2ce78375f6
logical/request: store the entire http.Request object instead (#7412)
This allows logical operations (along with a non-nil response writer) to
process http handler funcs within the operation function while keeping
auth and audit checks that the logical request flow provides.
2019-09-06 12:40:15 -07:00
Mike Jarmy
c48159ea3a AWS upgrade role entries (#7025)
* upgrade aws roles

* test upgrade aws roles

* Initialize aws credential backend at mount time

* add a TODO

* create end-to-end test for builtin/credential/aws

* fix bug in initializer

* improve comments

* add Initialize() to logical.Backend

* use Initialize() in Core.enableCredentialInternal()

* use InitializeRequest to call Initialize()

* improve unit testing for framework.Backend

* call logical.Backend.Initialize() from all of the places that it needs to be called.

* implement backend.proto changes for logical.Backend.Initialize()

* persist current role storage version when upgrading aws roles

* format comments correctly

* improve comments

* use postUnseal funcs to initialize backends

* simplify test suite

* improve test suite

* simplify logic in aws role upgrade

* simplify aws credential initialization logic

* simplify logic in aws role upgrade

* use the core's activeContext for initialization

* refactor builtin/plugin/Backend

* use a goroutine to upgrade the aws roles

* misc improvements and cleanup

* do not run AWS role upgrade on DR Secondary

* always call logical.Backend.Initialize() when loading a plugin.

* improve comments

* on standbys and DR secondaries we do not want to run any kind of upgrade logic

* fix awsVersion struct

* clarify aws version upgrade

* make the upgrade logic for aws auth more explicit

* aws upgrade is now called from a switch

* fix fallthrough bug

* simplify logic

* simplify logic

* rename things

* introduce currentAwsVersion const to track aws version

* improve comments

* rearrange things once more

* conglomerate things into one function

* stub out aws auth initialize e2e test

* improve aws auth initialize e2e test

* finish aws auth initialize e2e test

* tinker with aws auth initialize e2e test

* tinker with aws auth initialize e2e test

* tinker with aws auth initialize e2e test

* fix typo in test suite

* simplify logic a tad

* rearrange assignment

* Fix a few lifecycle related issues in #7025 (#7075)

* Fix panic when plugin fails to load
2019-07-05 16:55:40 -07:00
Brian Kassouf
b435028f3f
Raft Storage Backend (#6888)
* Work on raft backend

* Add logstore locally

* Add encryptor and unsealable interfaces

* Add clustering support to raft

* Remove client and handler

* Bootstrap raft on init

* Cleanup raft logic a bit

* More raft work

* Work on TLS config

* More work on bootstrapping

* Fix build

* More work on bootstrapping

* More bootstrapping work

* fix build

* Remove consul dep

* Fix build

* merged oss/master into raft-storage

* Work on bootstrapping

* Get bootstrapping to work

* Clean up FMS and node-id

* Update local node ID logic

* Cleanup node-id change

* Work on snapshotting

* Raft: Add remove peer API (#906)

* Add remove peer API

* Add some comments

* Fix existing snapshotting (#909)

* Raft get peers API (#912)

* Read raft configuration

* address review feedback

* Use the Leadership Transfer API to step-down the active node (#918)

* Raft join and unseal using Shamir keys (#917)

* Raft join using shamir

* Store AEAD instead of master key

* Split the raft join process to answer the challenge after a successful unseal

* get the follower to standby state

* Make unseal work

* minor changes

* Some input checks

* reuse the shamir seal access instead of new default seal access

* refactor joinRaftSendAnswer function

* Synchronously send answer in auto-unseal case

* Address review feedback

* Raft snapshots (#910)

* Fix existing snapshotting

* implement the noop snapshotting

* Add comments and switch log libraries

* add some snapshot tests

* add snapshot test file

* add TODO

* More work on raft snapshotting

* progress on the ConfigStore strategy

* Don't use two buckets

* Update the snapshot store logic to hide the file logic

* Add more backend tests

* Cleanup code a bit

* [WIP] Raft recovery (#938)

* Add recovery functionality

* remove fmt.Printfs

* Fix a few fsm bugs

* Add max size value for raft backend (#942)

* Add max size value for raft backend

* Include physical.ErrValueTooLarge in the message

* Raft snapshot Take/Restore API  (#926)

* Inital work on raft snapshot APIs

* Always redirect snapshot install/download requests

* More work on the snapshot APIs

* Cleanup code a bit

* On restore handle special cases

* Use the seal to encrypt the sha sum file

* Add sealer mechanism and fix some bugs

* Call restore while state lock is held

* Send restore cb trigger through raft log

* Make error messages nicer

* Add test helpers

* Add snapshot test

* Add shamir unseal test

* Add more raft snapshot API tests

* Fix locking

* Change working to initalize

* Add underlying raw object to test cluster core

* Move leaderUUID to core

* Add raft TLS rotation logic (#950)

* Add TLS rotation logic

* Cleanup logic a bit

* Add/Remove from follower state on add/remove peer

* add comments

* Update more comments

* Update request_forwarding_service.proto

* Make sure we populate all nodes in the followerstate obj

* Update times

* Apply review feedback

* Add more raft config setting (#947)

* Add performance config setting

* Add more config options and fix tests

* Test Raft Recovery (#944)

* Test raft recovery

* Leave out a node during recovery

* remove unused struct

* Update physical/raft/snapshot_test.go

* Update physical/raft/snapshot_test.go

* fix vendoring

* Switch to new raft interface

* Remove unused files

* Switch a gogo -> proto instance

* Remove unneeded vault dep in go.sum

* Update helper/testhelpers/testhelpers.go

Co-Authored-By: Calvin Leung Huang <cleung2010@gmail.com>

* Update vault/cluster/cluster.go

* track active key within the keyring itself (#6915)

* track active key within the keyring itself

* lookup and store using the active key ID

* update docstring

* minor refactor

* Small text fixes (#6912)

* Update physical/raft/raft.go

Co-Authored-By: Calvin Leung Huang <cleung2010@gmail.com>

* review feedback

* Move raft logical system into separate file

* Update help text a bit

* Enforce cluster addr is set and use it for raft bootstrapping

* Fix tests

* fix http test panic

* Pull in latest raft-snapshot library

* Add comment
2019-06-20 12:14:58 -07:00
Jeff Mitchell
170521481d
Create sdk/ and api/ submodules (#6583) 2019-04-12 17:54:35 -04:00