Commit Graph
100 Commits
Author SHA1 Message Date
Johan Brandhorst-Satzkorn 6081b6c58d internal/credential: simplify TestObject test helper (#3899)
The TestObject test helper previously returned an error,
but it's easier to have it perform the error check itself,
as it conventionally done with test helpers.
2023-10-30 11:03:04 -07:00
Johan Brandhorst-Satzkorn 940eb61282 sqltest: fix typo (#3886) 2023-10-26 11:18:41 -07:00
Johan Brandhorst-Satzkorn 894927ffd2 internal/host: fix inconsistent receiver (#3894)
This is a lint error but wasn't caught because it was a
historic problem. It's appearing again now because we're
adding another method to this type as part of the
pagination workflow.
2023-10-26 11:16:59 -07:00
Johan Brandhorst-Satzkorn 2e0587bff0 credential: fix lint errors (#3746)
The existing pattern was subject to a bug whereby a lock
value was copied every time the value was passed around.
This was happening because of the use of an embedded
protobuf type. To avoid copying a mutex, use a pointer
type in the embedding.

Also fixes a few linter warnings complaining about the use
of unkeyed literals.
2023-09-19 09:17:42 -07:00
Johan Brandhorst-Satzkorn f89515a19c all: avoid mutating global state in parallel tests (#3687)
The SetupSuiteTargetFilters globally mutates the function used for logic
inside the target handler service. This means that we could get
inconsistent logical behavior in certain tests that were run in parallel,
since the logic can change at runtime. Ensure tests that make use
of this function are never run in parallel with other tests.
2023-09-07 11:52:00 -07:00
Johan Brandhorst-Satzkorn 4789c00177 ui: bump UI commit (#3688)
The old commit artifact has expired.
2023-09-07 11:02:14 -07:00
Johan Brandhorst-Satzkorn 78161c0187 Revert "Revert "Upgrade Go version (#3677)"" (#3681)
This reverts commit 10837ab19569f41d272c1803bd98a70b0cd7a0df.

M
E
T
A
2023-09-06 13:48:04 -07:00
Johan Brandhorst-Satzkorn b2c0300dac Revert "Upgrade Go version (#3677)" (#3680)
This reverts commit 2b2eada393. The change
breaks out integration tests because the new Docker image is not
available yet. We'll revert this change once it is.
2023-09-06 11:53:39 -07:00
Johan Brandhorst-Satzkorn 2b2eada393 Upgrade Go version (#3677)
This avoids an RCE in the Go tooling and fixes
some JS escaping in html/template.

See https://groups.google.com/g/golang-announce/c/Fm51GRLNRvM?pli=1
for more information.
2023-09-06 11:07:44 -07:00
Johan Brandhorst-Satzkorn a73db844fe internal/perms: Fix grant parser bugs (#3660)
* internal/perms: Fix grant parser bugs

This fixes two bugs in the grant parser:

1. The parser would accept "," as an output field when parsing from JSON.
  This would then make it into the canonical string,
  which would make it look like we had a trailing comma.
  Disallow the use of a comma as an output field.
2. The parser would accept empty IDs when parsing from JSON.
  Make this behavior consistent with the text behavior.

* internal/perms: also handle empty IDs in text form

* internal/perms: disallow any commas

Commas anywhere in ids or output fields corrupt
the canonical output string.

* internal/perms: disallow any reserved characters

id, ids and actions could all contain one of the
reserved characters ",", "=" or ";" when used with
JSON.
2023-09-06 09:11:56 -07:00
Johan Brandhorst-Satzkorn 9e955c806e ci: attempt to silence action linter (#3659)
The lint warnings are bogus but they keep failing so lets
try to work around the suggested issues.
2023-09-01 09:18:15 -07:00
Johan Brandhorst-Satzkorn 477deeb294 Fix fuzz corpus upload (#3647) 2023-08-31 09:28:15 -07:00
Johan Brandhorst-Satzkorn 90cf20d0dd handlers/targets/tcp: run tests in parallel (#3639)
This reduces the runtime from 79s to 24s on my machine
2023-08-28 15:08:20 -07:00
Johan Brandhorst-Satzkorn e108ae40ad Upgrade to Go 1.21 (#3573)
* Upgrade to Go 1.21

* event: remove tests depending on pointer comparison

The test now just tests that the logger is non-nil. For
some reason the old test was broken by upgrading
to Go 1.21.0.

* api: use dummy Host header for unix sockets

When using unix sockets with the net/http.Client,
we cannot use the unix socket address directly
in the Host header, as it fails the validation step.
Instead, use a dummy address in the Host header.
2023-08-15 12:04:58 -07:00
Johan Brandhorst-Satzkorn bae219d461 Re-enable copywrite with hack (#3569)
* Ignore license change commit from blame

This changed almost all the files in the repo

* Re-enable copywrite with hack

Adds a hack that removes existing copyright headers
from files before rerunning copywrite with directory
specific configuration.
2023-08-11 15:02:29 -07:00
Johan Brandhorst-Satzkorn 5e78fc72c5 tests: add timeout to key version destruction test (#3537) 2023-08-03 11:08:28 -07:00
Johan Brandhorst-Satzkorn c644396916 server: allow release version to be set in test (#3517)
The old logic made it impossible for the caller to set
the release version with WithReleaseVersion. Only
set the release version when it's not explicitly set already.
2023-07-31 09:41:22 -07:00
Johan Brandhorst-SatzkornandDan Heath 28de3d712b Connect option docs (#3424)
* docs: add ssh connect helper

Really just splits this up into a separate heading. We will add
more connect helpers as we go.

* docs: add RDP connect helper

* docs: add postgres connect helper

* docs: add http connect helper

* docs: add kube connect helper

* docs: remove duplicate mention of helpers

* docs: Copy edits to dev-mode topic

* docs: Copy edits to hcp topic

* docs: Minor copy edits

---------

Co-authored-by: Dan Heath <76443935+Dan-Heath@users.noreply.github.com>
2023-07-21 15:12:55 -04:00
Johan Brandhorst-Satzkornandstellarsquall 5ea25ccf2a docs: add code blocks to LDAP auth method docs (#3437)
* docs: add code blocks to LDAP auth method docs

The code blocks make it much clearer what is and isn't an example.

* adds user_filter parameter code syntax style

---------

Co-authored-by: stellarsquall <stellarsquall@protonmail.ch>
2023-07-13 17:24:14 -04:00
Johan Brandhorst-Satzkorn 2ae007d61e cmd: fix session recording download flag help (#3351)
When using an alias, we automatically add a little
blurb to the end of the flag help. When not terminating
the flag help with a full stop, this looks a bit odd. Add
full stops to all the download flags for consistency.
2023-06-22 07:31:21 -07:00
Johan Brandhorst-Satzkorn f698f2a442 systemd: merge controller/worker config examples (#3342)
Our systemd setup included both a controller and worker
configuration example, and a %i templated config file meant
to be used to determine which to use. For ease of use, merge
the two config files into a predictably named "boundary.hcl".
2023-06-21 13:51:13 -07:00
Johan Brandhorst-Satzkorn 9474b373b8 api: remove create from auth-tokens help (#3341)
The auth-tokens help command included a reference to
a non-existent auth-tokens create command. Replace the
default help and also add a helpful pointer to the authenticate
command.
2023-06-20 13:17:43 -07:00
Johan Brandhorst-Satzkorn 888349c99f website: add separate note about worker tags (#3306)
Using worker tags in expressions can be confusing, this adds
a note to make it clear how to match values in tags.
2023-06-12 09:15:40 -04:00
Johan Brandhorst-Satzkorn e4f49e1bb0 api: add classification to session recordings (#3300) 2023-06-08 23:01:39 -07:00
Johan Brandhorst-Satzkorn ebcd6d2828 api: remove connection ID (#3298)
Removing this until we figure out why it's sometimes missing.
May add it back again later.
2023-06-08 09:15:12 -07:00
Johan Brandhorst-Satzkorn 43f3c6bd68 Upgrade Go version to 1.20.5 (#3293)
Go 1.20.5 contains security fixes for the runtime and the compiler
2023-06-07 10:09:43 -07:00
Johan Brandhorst-Satzkorn 610df9892b all: propagate more history metadata (#3279)
A few target and host properties were missed when reading historical
data from the history tables.
2023-06-05 10:19:11 -07:00
Johan Brandhorst-Satzkorn 97977f1995 update perms table for session recordings and storage buckets (#3253) 2023-06-01 12:45:27 -07:00
Johan Brandhorst-Satzkorn 0c8177590f Upgrade grpc-gateway dependency (#3257)
* proto: correct classification of authz token

The target authorization token had the invalid classification
"private". Fortunately, classification is a fail-closed system,
so this won't have exposed users authorization tokens, but
we should still use the correct classification. Use "secret".

* scripts: add Go script to remove gotags comments

The new version of grpc-gateway includes our gotags
comments in the generate swagger documentation. This
script removes all mentions of these.

* Upgrade grpc-gateway dependency

Mainly we need this to fix generation of our docs side API docs,
but it also includes a nice fix for the new Download RPC, i.e. it
now contains the correct response schema (a binary stream).
2023-06-01 06:41:09 -07:00
Johan Brandhorst-Satzkorn c765db2bb8 Upgrade go-secure-stdlib dependencies (#3256) 2023-05-31 17:58:48 -07:00
Johan Brandhorst-Satzkorn 3e07b2ffaf bsr: rename fields and remove project id from meta 2023-05-31 12:18:24 +00:00
Johan Brandhorst-Satzkorn 64764e29e5 bsr: invert credential, cred store relationship
This lifts the credential sources up to the top of
the SessionMeta struct, avoiding indirection through
the credential stores.
2023-05-31 12:18:24 +00:00
Johan Brandhorst-Satzkorn e0700570a2 bsr: add endpoint to session meta
The endpoint stores the address of the host
the egress worker proxies to.
2023-05-31 12:18:24 +00:00
Johan Brandhorst-Satzkorn 59f78ac1f8 config: allow wasm execution under UI CSP
The wasm-unsafe-eval option is necessary for the asciinema
player on the Admin UI
2023-05-31 12:18:24 +00:00
Johan Brandhorst-Satzkorn 98e0b9db98 commands: add created, updated to recordings 2023-05-31 12:18:22 +00:00
Johan Brandhorst-Satzkorn 3374d32a55 api: add created, updated times to conn, chan
In addition to session recordings, connection and
channel recordings now also include the created and
updated time.
2023-05-31 12:18:21 +00:00
Johan Brandhorst-Satzkorn 74d10da7b4 bsr: remove duplicate target scope info
We were storing the project ID both as part of the scope
and as a field directly on the target. Remove the extra field.
2023-05-31 12:18:19 +00:00
Johan Brandhorst-Satzkorn 15524f3408 api: add created, updated times to recordings 2023-05-31 12:18:19 +00:00
Johan Brandhorst-Satzkorn 4387a59ce5 sessionrecordings: add endpoint 2023-05-31 12:18:18 +00:00
Johan Brandhorst-Satzkorn 89befba55e api: add state and error details fields to recordings 2023-05-31 12:18:18 +00:00
Johan Brandhorst-Satzkorn 11893a8885 db: add state and error_details to recording 2023-05-31 12:18:17 +00:00
Johan Brandhorst-Satzkorn af8e4d63be db: add channel summary details 2023-05-31 12:18:17 +00:00
Johan Brandhorst-Satzkorn 281989e595 regenerate API files 2023-05-31 12:18:17 +00:00
Johan Brandhorst-Satzkorn 328b039138 scopes: fix test expectation 2023-05-31 12:18:15 +00:00
Johan Brandhorst-Satzkorn ad62df6b36 cluster: pass controller ext to authorize conn
Make the controller extension availalbe to the protocol
context constructor.
2023-05-31 12:18:13 +00:00
Johan Brandhorst-Satzkorn 5837d6f387 target: add PostSessionAuthorization callback
The callback is called for any steps that need to be performed
after a successful authorization but before returning to the user.
2023-05-31 12:18:13 +00:00
Johan Brandhorst-Satzkorn 13e1196797 target: add error handling to authorize session
Attempt to undo operations if there are failures during
session authorization.
2023-05-31 12:18:13 +00:00
Johan Brandhorst-Satzkorn 517fc91ebf target: return selected worker when authorizing 2023-05-31 12:18:13 +00:00
Johan Brandhorst-Satzkorn 6d219bd5d1 target: add controller extension to service handler
The controller extension can be used to access types unavailable
in OSS.
2023-05-31 12:18:13 +00:00
Johan Brandhorst-Satzkorn 7632143861 add session recording API definitions 2023-05-31 12:18:10 +00:00
Johan Brandhorst-Satzkorn 7bb44b46f5 internal/db: add session recording tables
Add the following new tables used for storing session recordings:

* recording_session
* recording_connection
* recording_channel
* recording_channel_ssh
* storage_bucket
2023-05-31 12:18:10 +00:00
Johan Brandhorst-Satzkorn e04438b7f8 authmethods: fix test broken by LDAP
These tests were never updated for LDAP
2023-05-02 18:00:24 -07:00
Johan Brandhorst-Satzkorn c503fca894 .github: fix test matrix script
The test matrix script was excluding directories that
only contained external package tests (i.e. tests packages
with _test suffix). The following tests were not being run:

    ./internal/daemon/controller/common/scopeids
    ./internal/daemon/controller/handlers/authtokens
    ./internal/daemon/controller/handlers/groups
    ./internal/daemon/controller/handlers/host_catalogs
    ./internal/daemon/controller/handlers/host_sets
    ./internal/daemon/controller/handlers/hosts
    ./internal/daemon/controller/handlers/roles
    ./internal/daemon/controller/handlers/scopes
    ./internal/daemon/controller/handlers/sessions
    ./internal/daemon/controller/handlers/targets/tcp
    ./internal/daemon/controller/handlers/users
    ./internal/db/schema/internal/edition
    ./internal/db/schema/internal/provider
    ./internal/db/schema/migrations/oss
    ./internal/scheduler/cleaner
    ./internal/tests/api/accounts
    ./internal/tests/api/authmethods
    ./internal/tests/api/authtokens
    ./internal/tests/api/credentiallibraries
    ./internal/tests/api/credentials
    ./internal/tests/api/credentialstores
    ./internal/tests/api/groups
    ./internal/tests/api/hostcatalogs
    ./internal/tests/api/hosts
    ./internal/tests/api/hostsets
    ./internal/tests/api/managedgroups
    ./internal/tests/api/roles
    ./internal/tests/api/scopes
    ./internal/tests/api/sessions
    ./internal/tests/api/targets
    ./internal/tests/api/users
    ./internal/tests/api/workers
    ./internal/util
    ./testing/dbtest
    ./testing/internal/e2e/tests/aws
    ./testing/internal/e2e/tests/database
    ./testing/internal/e2e/tests/static
    ./testing/internal/e2e/tests/static_with_vault
2023-05-02 17:34:39 -07:00
Johan Brandhorst-Satzkorn c1a61b9e34 internal/tests/cluster: switch flaky test to polling (#3153)
* internal/tests/cluster: switch flaky test to polling

Also extend deadline from 10 seconds to 1 minute, hopefully
this should fix any flakiness in this test.

* fixup! internal/tests/cluster: switch flaky test to polling
2023-04-05 18:45:52 -04:00
Johan Brandhorst-Satzkorn ecdb77b584 internal/db/sqltest: fix sessions aggregate (#3152)
The sessions aggregate was inserting host_id and host_set_id,
columns which are no longer present on the session table. Also
fix the test that guards against regressions like this in the future.
2023-04-05 12:57:25 -04:00
Johan Brandhorst-Satzkorn bc31892f29 internal/db: add set_once_columns function (#3117)
* internal/db: add set_once_columns function

Also replace existing before_soft_delete_credential_vault_store
function and trigger with the new function.

* internal/db/schema: add note to replaced definitions
2023-03-28 13:35:26 -04:00
Johan Brandhorst-Satzkorn e3fc289733 Update buf dependencies (#3116) 2023-03-24 17:01:10 -04:00
Johan Brandhorst-Satzkorn 0e1b020960 fix(all): make copywrite ignores stricter (#2990)
The previous ignore matched oplog_entry.go accidentally.
2023-02-21 15:01:15 -05:00
Johan Brandhorst-Satzkorn 18eed58ec5 fix(targets): Use correct error string in enterprise (#2984)
In enterprise the error is different, so we need a different
test error string to compare against. Create a variable
that can be overwritten in the enterprise repo.
2023-02-16 20:34:25 -05:00
Johan Brandhorst-Satzkorn 8a0ee97f3b fix(targets): Readd WorkerFilterDeprecationMessage (#2982)
This variable is updated in the enterprise repo and needs to stay.
2023-02-16 17:56:18 -05:00
Johan Brandhorst-Satzkorn ac3543bdfb fix(targets): Use correct field name in deprecation warning (#2978) 2023-02-16 14:36:23 -05:00
Johan Brandhorst-Satzkorn ca3c66e7b2 fix: Exempt enterprise files from copywrite (#2971) 2023-02-16 11:00:57 -05:00
Johan Brandhorst-Satzkorn cf412b95a2 fix: Support streaming HTTP responses (#2956)
* all: Upgrade listenerutil dependency

The new listenerutil implements http.Flusher, which is necessary
for streaming responses from the grpc-gateway to work.

* daemon/controller: Remove newline delimiter in streaming responses

The default gRPC-Gateway HTTPBody marshaler uses newlines
as a delimiter. This introduces newlines in our streamed responses.
Wrapping the default marshaler lets us define a nil delimiter, which
ensures our streaming responses are unaffected by the server side
chunking.
2023-02-13 14:56:53 -05:00
Johan Brandhorst-Satzkorn 4146c0c55d Upgrade Go version to 1.20 (#2898)
* chore: Upgrade Go version

* fix: Upgrade golangci-lint to support 1.20

* fix: Don't use t.SetEnv in parallel tests

This is a panic in Go 1.20 and it sounds like a recipe
for distaster in general.
2023-02-10 11:16:03 -05:00
Johan Brandhorst-Satzkorn 48e4fcce25 fix: remove file number dependency from test
This was failing because of the added comments.
This isn't a crucial part of the test, so remove it.
2023-02-03 15:55:38 -08:00
Johan Brandhorst-Satzkorn 430e372333 chore: Ignore license headers from blame history 2023-02-03 15:55:35 -08:00
Johan Brandhorst-Satzkorn 3c29308673 chore: Add license headers to all files 2023-02-03 15:54:27 -08:00
Johan Brandhorst-Satzkorn dcb499ed4f chore: Add copywrite Makefile target
The new copywrite target can be used to add any
missing license headers.
2023-02-03 15:54:27 -08:00
Johan Brandhorst-Satzkorn 501761a564 chore: Add changelog entry for job_run fix (#2897) 2023-02-03 14:57:33 -05:00
Johan Brandhorst-Satzkorn 55259029f1 Add job run cleaner (#2866)
* chore: remove duplicate import

* feat: Add job run cleaner

The new job cleans job runs older than a configured interval.
Configure the job to clean jobs older than 1 minute.
2023-01-31 20:41:33 -05:00
Johan Brandhorst-Satzkorn e8588620f3 Add Heimdall summary (#2830)
Used by the CORE SRE team Heimdall product to give
quick overview of all the HashiCorp repositories.
Initially this just adds some very basic information
about this repository. Could be expanded if we
expand the use of Heimdall.
2023-01-24 12:29:45 -05:00
Johan Brandhorst-SatzkornandJeff Mitchell 61c90c5623 Add grant parsing fuzz test (#2534)
* testing(perms): Add Parse fuzz test

I ran this for a few minutes and it didn't discover anything catastrophic.

* Add roundtrip tests

* Fix invalid unicode parsing, empty output fields

* Do the unicode conversion once on input

* Remove incorrect fix for empty output fields

* Allow empty output_fields

This is the same behavior as output_fields=,

* Add tests back, make JSON behaviour consistent

* Rework the output fields mechanism to fix some bugs such as properly handling no fields

* Change signature of Fields

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2023-01-06 18:27:19 -05:00
Johan Brandhorst-Satzkorn ef6f94f496 chore: Remove unused CI job (#2764) 2023-01-06 14:45:02 -05:00
Johan Brandhorst-Satzkorn 240278cbf1 fix(docs): Use "root" to reference the root key (#2700)
The "root" identifier is how we identify the root key in configuration,
so it is the phrase we should use in this documentation.
2022-12-12 11:24:58 -05:00
Johan Brandhorst-Satzkorn 5d48b10123 Upgrade Go (#2699)
* fix(ci): Make goinstall read from .go-version

* Upgrade Go version

Go version 1.19.4 contains a security fix that affects all HTTP/2
servers.
2022-12-09 15:58:40 -05:00
Johan Brandhorst-Satzkorn eb113b5c9e fix(db): Reorder migrations (#2688)
Migration numbers need to be consistent between version upgrades.
The migrations for the key lifecycle management were merged
into v0.11.1 as number 56, but are currently 58 in main.
This reorders them down to 56, fixing an issue when
migrating from 0.11.1 to main.
2022-12-08 13:40:14 -05:00
Johan Brandhorst-Satzkorn 6d25b35b4e Add KMS rotation/destruction feature to the changelog and docs (#2600)
* Add initial changelog entry

* feat(docs): Add initial stab at docs for KMS rotation/destruction

* fixup! Add initial changelog entry

* Review comments
2022-12-01 13:32:35 -05:00
Johan Brandhorst-SatzkornandDan Heath df02501dcc Create new "previous-root" key purpose for root key migrations (#2639) (#2648)
* Update go-kms-wrapping dependency

* Apply changes suggested by Jeff

* Fix listener test

* Add note about config fix to CHANGELOG

* Review comments

Co-authored-by: Dan Heath <76443935+Dan-Heath@users.noreply.github.com>

Co-authored-by: Dan Heath <76443935+Dan-Heath@users.noreply.github.com>
2022-11-24 20:07:37 -05:00
Johan Brandhorst-Satzkorn 8908dccf6d Forward port some release fixes (#2631)
* fix(worker): Verify contents of loaded session (#2629)

* fix(worker): Verify contents of loaded session

Previously, it was possible for an empty private key to be used
when the session had no user or project associated with it.
The new checks guarantee that we will fail gracefully in these
cases.

* Check against len instead of nil

* Add CHANGELOG

* fix(session): Always invoke all parts of session cancel trigger

The session cancelation trigger would not set the key_id to null
appropriately if another one of the fields on the session was
already null, since that case statement would be matched first.
The new structure matches all statements, in case any of them have
special logic (such as in the project case).
2022-11-17 18:21:20 -05:00
edd323b73a Key Rotation/Destruction (#2477) (#2607)
* Key Rotation/Destruction (#2477)

* fix: Correct kms.CreateKeys comment

This method does not return anything.

* feat(kms): Add new ListKeys method

The new ListKeys method wraps the underlying KMS wrapper,
returning all the keys in the scope specified.

* feat(scopes): Add new scope actions for key management

Adds list-keys, rotate-keys and revoke-keys actions for scopes.

* feat(scopes): Add ListKeys API endpoint

This new endpoint lists all keys in a scope

* feat(api): Add ListKeys to Scopes client

This has to be a custom function because it is a custom action
and doesn't map well to any of the existing templates, or
generalises well in a way that would make it reasonable
to create a new template.

* feat(cli): Add new scopes list-keys command

* add RotateKeys function to the kms repository

* Add Rotate Keys Endpoint to Scopes Api (#2360)

* add rotate keys endpoint

* add tests for RotateKeys endpoint

* remove that one comment I forgot about

* addressing more PR comments

* Add Rotate Keys CLI Command (#2395)

* add cli command and client

* add bats tests

* fix some info text and pr comments

* write a new rotate keys description

* Add Missing DEK Foreign Keys (#2408)

* add missing fks

* mark key as nullable in gorm

* update tests to use a new wrapper with a real key_id

* fix formatting in test and add keys for auth_token test

* replace key values

* revert postgres_40_01_test.go

* style: reformat sql for readability

* refactor: change type of key_id columns to kms_private_id

* Store key_id and scope_id with oplog entries, re-type columns referencing data key version (#2431)

* fix(db): Correct types of data key version referencers

* fix(oplog): Fix missing error handling

* feat(oplog): Store key_id and scope_id with oplog entries

This migration truncates all existing oplog entries, as
migrating existing data would have been complex and
likely unnecessary.

* Update view references

* Always delete oplog entries when dropping keys

* Fix rebase issues

* Fix sql tests

* Add schema for new kms destruction jobs (#2479)

* feat: Add schema for new kms destruction jobs

The schema lets us manage destruction jobs per-table
while providing a guarantee that only one run is running
at a time.

* Apply suggestions from code review

Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>

* Fix table reference and tests

Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>

* update domain, api, and cli to all include key versions in outputs (#2472)

* update domain, api, and cli to all include key versions in outputs

* fix go sum

* add migration to fix immutable error

* fix final test issue as well as make gen issue

* rebase and fix

* address johan pr comments

* make gen, didn't realize comments were included

* update migrations based on new migration 55 file 03

* Move migrations to 56

* feat: Add key version rewrapping function registry (#2478)

The new RegisterTableRewrapFn can be used by a domain
to register a callback to use when rewrapping data in a
specific table name.

* feat(kms): Add scopeId to RewrapFn (#2539)

This makes it much easier for rewrap functions to look up
the correct wrapper and limit the number of rows searched.

* Update Root Cert Proto Definition (#2542)

* update root cert proto definition to properly identify public_key as the table primary key

* add the test fix as well

* Rewrap Functions for Encrypted Tables (#2532)

* add oidc rewrap

* add argon2 config rewrap

* add auth token rewrapping

* add worker auth cert rewrapping

* check the err

* add username password credential rewrapping

* add ssh private key credential rewrapping

* add vault client certificate rewrap function

* add host catalog secret rewrap function

* cleanup a little

* add host vault token rewrap function

* add session credential rewrap function

* add session rewrap function

* add worker auth rewrap function

* update test to include full assert gamut

* add session rewrap function TEST

* bring all tests up to current standards, make more readable, and include full assert gamut

* rework all rewrap functions to utilize scope id

* update comments, queries, sql refs, etc, in response to PR comments

* forgot a comment

* remove hmac updates and fix a couple comments again

* Rewrapping Registered Tables Test (#2555)

* add the registered table test as well as the two missing rewrap functions

* address pr comments, add db r/w conversions, cmp.diff, sql comment, remove (now) faulty immutable test

* Add ability to list key version destruction jobs, recurring jobs and destroying key versions (#2498)

* feat(kms): Add ability to list data key version destruction jobs

* feat(scopes): Add ListKeyVersionDestructionJobs

* feat(cli): Add list-key-version-destruction-jobs

* feat(kms): Add recurring job that performs table rewrapping

The new recurring job runs for each job table with a registered
rewrapping callback. It attempts to become the running run and
start its rewrapping, gracefully handling sudden interruptions
by resuming it's work if it finds evidence of sudden interruption.

* feat(kms): Add recurring job for destroying key versions

The new job monitors the database for data key version destruction
jobs that have finished rewrapping all its data, performing
the final data key version revocation.

* feat(kms): Add DestroyKeyVersion

DestroyKeyVersion immediately destroys a key version
if it is a root key version or a data key version
which encrypts no data. If the data key version
encrypts data which needs to be rewrapped, it
queues an asynchronous job to complete the rewrapping
operation.

* feat(scopes): Add DestroyKeyVersion API endpoint

* feat(cli): Add scopes destroy-key-version CLI command

* Ensure all secret updates include key ID (#2556)

* feat(all): Ensure all secret updates include key ID

When updating a secret, it is paramount that the key ID
is also updated, as it is the only means we have of ensuring
that we only destroy keys once there is no more data
associated with the key.

* Remove fix to session repository for now

This breaks the current private key derivation method

* add new encrypt/decrypt funcs and made necessary proto changes (#2557)

* add new encrypt/decrypt funcs and made necessary proto changes

* address all PR comments

* fix test panic

* add param checking to rewraps

* fix(schema): Correctly organize migrations again

* Review comments part 1

* Review comments part 2

* Review comments part 3

* Store cert private key, encrypt tofu token (#2583)

* fix(session): store cert private key, encrypt tofu token

Previously, we would derive a session certificate private key from
the session key used in each project, and not store the key. We
would also encrypt the tofu token with the database key but not
store a reference to this key in the database.

This change fixes this by replacing our key derivation with a key
generation step, and instead store the generated key, encrypted,
in the database. We also ensure that any new tofu tokens are
encrypted with the same key.

To handle existing sessions, we lazily rewrite the sessions whenever
a user lists them. There is a minor risk that a user could end up
destroying the database key that encrypts the tofu token before
that session has been rewrapped, but this is going to be rare and
temporary.

* feat(session): Allow the random source for secrets to be configured

* Review comments

* Minor fixes

* More minor fixes

* More small fixes

Co-authored-by: Danielle Miu <dani.miu@hashicorp.com>
Co-authored-by: Danielle <29378233+DanielleMiu@users.noreply.github.com>
Co-authored-by: Michael Gaffney <mike@gaffney.cc>
Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>

* fix(session): Unset session key ID when scope is deleted

Unsetting the key ID allows the session to live beyond the lifetime of
the scope, while allowing the scope to cascade delete its keys.

* fix(migrations): Rewrite migration 56 tests

These tests can no longer use the normal test helpers
as they try to use the new oplog table structure, so we
have to manually write all the interactions.

* fix(migrations): Rename migration 58 file name

This was the name used in the release branch, update
it to the new migration number.

* fix(e2e): Add some comments and debug to kms tests

* fix(session): Handle empty project and user IDs in read

When a project or user is deleted, the session is automatically
canceled and the respective field on the session is unset.
LookupSession did not handle this case gracefully, and would
error on decryption in this state. Skip decrypting sessions that
do not have either a user or project to avoid this error. The
decrypted values are not used for a canceled session.

* Fix worker test

* Increase test timeout

Co-authored-by: Danielle Miu <dani.miu@hashicorp.com>
Co-authored-by: Danielle <29378233+DanielleMiu@users.noreply.github.com>
Co-authored-by: Michael Gaffney <mike@gaffney.cc>
Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
2022-11-16 18:17:28 -05:00
Johan Brandhorst-Satzkorn a216c701ee Silence events from DB errors (#2601) (#2602)
If callers want errors to create events, they can do so
by wrapping the error. Sometimes we don't want db
errors to be events, and before this there was no way
to supress them.
2022-11-09 17:04:05 -05:00
Johan Brandhorst-Satzkorn f57454b6b9 Rewrite interface{} to any (#2535)
* chore: Rewrite interface{} to any

* Add ignore revs
2022-10-25 19:29:38 -04:00
Johan Brandhorst-Satzkorn da9adb0c02 feat: Build docker dev images for specified platform (#2493)
Previously, building this target on an ARM machine would
produce an image with a amd64 binary inside an arm
OS.
2022-09-26 11:39:13 -04:00
Johan Brandhorst-SatzkornandTimothy Messier 5dbcda512a Fix enos bats test errors (#2468)
* test(cli): Remove skips in CI for cli tests

* fix(enos): Fix enos bats tests

The tests still sometimes suffer from timing issues,
but I was able to run a successful run (setup, run, destroy)
of the tests from my machine at least once.

There were 2 issues:

- Some tests in groups.bats were hardcoding the default user id
- The default grants for a user in a project were missing
   the permission to connect to a target. We now add this
   explicitly.

Co-authored-by: Timothy Messier <tim.messier@gmail.com>
2022-09-20 14:39:28 -04:00
Johan Brandhorst-SatzkornandYoko Hyakuna 5dc7e7f55c doc: Add link to generated API docs on API page (#2460)
* doc: Add link to generated API docs on API page

This makes it easier to find the generated API docs from the API
description page.

* Update website/content/docs/api-clients/api.mdx

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

Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>
2022-09-16 12:02:15 -04:00
Johan Brandhorst-Satzkorn f362bf0e1f chore: Upgrade to Go 1.19.1 (#2429) 2022-09-07 17:29:13 -04:00
Johan Brandhorst-Satzkorn 25f7caa3bf Update googleapis/grpc-gateway dependency (#2424)
This fixes some CI issues. See
https://docs.buf.build/faq#googleapis-failure for more
information.
2022-09-06 16:09:16 -04:00
Johan Brandhorst-Satzkorn de2c40fa77 Fork pgtap-docker to support arm64 (#2411)
* feat(sql): Fork pgtap to support arm64

This forks pgtap-docker and builds the image locally,
and updates our references to use our forked image.

* fixup! feat(sql): Fork pgtap to support arm64
2022-09-01 11:33:10 -04:00
Johan Brandhorst-Satzkorn aef9073fa6 Upgrade to Go 1.19 (#2347) 2022-08-25 12:12:24 -04:00
Johan Brandhorst-Satzkorn d709b97e18 fix(schema): Panic with error rather than function (#2391) 2022-08-24 20:42:21 -04:00
Johan Brandhorst-Satzkorn ac591d8283 fix(managed_groups): Fix validation function panic (#2390)
The logic would panic if no attributes were specified. Ensure
that attributes are non-nil before checking any sub fields.
2022-08-24 18:01:54 -04:00
Johan Brandhorst-Satzkorn d4fce6fbe1 fix: Move enos job attribute into enos-run workflow (#2374)
Maybe this will fix it? This doesn't make any sense.
2022-08-17 20:39:12 -04:00
Johan Brandhorst-Satzkorn 91e6857631 fix: Use correct yaml (#2373)
Didn't notice this until it failed on main
2022-08-17 20:27:26 -04:00
Johan Brandhorst-Satzkorn b6445adff0 feat: Stop enos jobs from failing CI pipelines (#2372)
Enos jobs are still a bit unstable, we should use them as
advisory for now. When they have gained more stability,
we can let them fail pipelines again.
2022-08-17 19:56:06 -04:00
Johan Brandhorst-Satzkorn e8b2104a80 fix: Update Dockerfile to use new PRODUCT_VERSION arg (#2370)
This is necessary since the merge of https://github.com/hashicorp/actions-docker-build/pull/25
2022-08-17 16:02:29 -04:00
Johan Brandhorst-Satzkorn 222a935223 Update grpc-gateway dependency (#2311)
* chore(deps): Update grpc-gateway dependency

This fixes an issue which would allow an attacker to trigger a
(recovered) panic in the gateway handler.

* fix(server): Use cmp.Diff instead of assert.Equal

Testify is not great at handling protobuf types, and
was for some reason returning a diff here when in
reality there is none. Switch to go-cmp for the
comparison to remove the error.
2022-08-11 20:24:14 -04:00
Johan Brandhorst-Satzkorn 2e3ec967f6 fix: Respect context when retrying (#2285)
Respect the cancellation of the context being passed in,
preventing us from retrying events that are doomed to fail.
2022-07-25 12:31:17 -04:00
Johan Brandhorst-Satzkorn 0315c999fe fix: support building docker images on M1 (#2250)
Now developers on the M1 can use
DEV_DOCKER_GOARCH=arm64 make docker-build-dev
2022-07-11 11:48:07 -04:00
Johan Brandhorst-Satzkorn a537491cbc chore: Update changelog with plugin fix (#2240) 2022-06-29 13:23:31 -04:00
Johan Brandhorst-Satzkorn ed406e2853 fix: Upgrade configutil dependency (#2239)
Fixes https://discuss.hashicorp.com/t/latest-boundary-versions-ignoring-plugins-execution-dir/41281

See: https://github.com/hashicorp/go-secure-stdlib/commit/bf6d78ef5b727b83b2f8f41b473eb9764b446df4
2022-06-28 15:12:36 -04:00