open-vault/http
Jeff Mitchell af802275bd
Fix response wrapping from K/V version 2 (#4511)
This takes place in two parts, since working on this exposed an issue
with response wrapping when there is a raw body set. The changes are (in
diff order):

* A CurrentWrappingLookupFunc has been added to return the current
value. This is necessary for the lookahead call since we don't want the
lookahead call to be wrapped.

* Support for unwrapping < 0.6.2 tokens via the API/CLI has been
removed, because we now have backends returning 404s with data and can't
rely on the 404 trick. These can still be read manually via
cubbyhole/response.

* KV preflight version request now ensures that its calls is not
wrapped, and restores any given function after.

* When responding with a raw body, instead of always base64-decoding a
string value and erroring on failure, on failure we assume that it
simply wasn't a base64-encoded value and use it as is.

* A test that fails on master and works now that ensures that raw body
responses that are wrapped and then unwrapped return the expected
values.

* A flag for response data that indicates to the wrapping handling that
the data contained therein is already JSON decoded (more later).

* RespondWithStatusCode now defaults to a string so that the value is
HMAC'd during audit. The function always JSON encodes the body, so
before now it was always returning []byte which would skip HMACing. We
don't know what's in the data, so this is a "better safe than sorry"
issue. If different behavior is needed, backends can always manually
populate the data instead of relying on the helper function.

* We now check unwrapped data after unwrapping to see if there were raw
flags. If so, we try to detect whether the value can be unbase64'd. The
reason is that if it can it was probably originally a []byte and
shouldn't be audit HMAC'd; if not, it was probably originally a string
and should be. In either case, we then set the value as the raw body and
hit the flag indicating that it's already been JSON decoded so not to
try again before auditing. Doing it this way ensures the right typing.

* There is now a check to see if the data coming from unwrapping is
already JSON decoded and if so the decoding is skipped before setting
the audit response.
2018-05-10 15:40:03 -04:00
..
auth_token_test.go Core handling of TTLs (#4230) 2018-04-03 12:20:20 -04:00
cors.go
forwarded_for_test.go dont reuse err on multiple goroutines (#4545) 2018-05-10 10:10:08 -07:00
forwarding_test.go Move to "github.com/hashicorp/go-hclog" (#4227) 2018-04-02 17:46:59 -07:00
handler.go X-Forwarded-For (#4380) 2018-04-17 18:52:09 -04:00
handler_test.go Fix tests from version update 2018-04-09 16:14:44 -04:00
help.go
help_test.go
http_test.go Unauthenticated endpoint to list secret and auth mounts (#4134) 2018-03-19 23:16:33 -04:00
logical.go Fix response wrapping from K/V version 2 (#4511) 2018-05-10 15:40:03 -04:00
logical_test.go Move to "github.com/hashicorp/go-hclog" (#4227) 2018-04-02 17:46:59 -07:00
plugin_test.go Move to "github.com/hashicorp/go-hclog" (#4227) 2018-04-02 17:46:59 -07:00
stub_assets.go OSS: Adding UI handlers and configurable headers (#390) 2018-04-03 09:34:01 -05:00
sys_audit_test.go
sys_auth_test.go Add options to mount tune and mount endpoints in preparation for versioning (#4155) 2018-03-21 12:04:27 -07:00
sys_config_cors_test.go
sys_generate_root.go Errwrap everywhere (#4252) 2018-04-05 11:49:21 -04:00
sys_generate_root_test.go
sys_health.go Sync some bits over 2018-01-22 21:44:49 -05:00
sys_health_test.go Sync some bits over 2018-01-22 21:44:49 -05:00
sys_init.go Re-add lost stored-shares parameter to operator rekey command. (#3974) 2018-02-14 16:10:45 -05:00
sys_init_test.go Fmt 2018-03-20 14:58:22 -04:00
sys_internal_test.go Kv preflight (#4430) 2018-04-23 15:00:02 -07:00
sys_leader.go
sys_leader_test.go
sys_lease_test.go
sys_mount_test.go Fix some tests 2018-04-10 00:22:23 -04:00
sys_mounts_test.go
sys_policy_test.go
sys_rekey.go Errwrap everywhere (#4252) 2018-04-05 11:49:21 -04:00
sys_rekey_test.go
sys_rotate_test.go
sys_seal.go Errwrap everywhere (#4252) 2018-04-05 11:49:21 -04:00
sys_seal_test.go
sys_wrapping_test.go Spelling (#4119) 2018-03-20 14:54:10 -04:00
testing.go
unwrapping_raw_body_test.go Fix response wrapping from K/V version 2 (#4511) 2018-05-10 15:40:03 -04:00