Commit Graph
221 Commits
Author SHA1 Message Date
Todd bc409bc7d4 Graceful shutdown blocks on running proxy handler connections (#2789) 2023-01-17 08:54:01 -08:00
Todd 38b74ce897 Provide a worker decryption function to proxy handlers (#2784) 2023-01-12 13:16:36 -08:00
Todd 0b87acb896 Always call PostConnectionHook in dialer and fix Dial bug (#2783) 2023-01-12 11:04:16 -08:00
Irena Rindos bb281e494f Fix status NPE if worker has been sitting waiting for registration (#2781) 2023-01-12 12:02:08 -05:00
Irena Rindos 5d5dc7524c update dial function doc to include options (#2776) 2023-01-11 13:26:37 -05:00
Irena Rindos d3d1fa0b55 initial commit (#2768) 2023-01-10 08:10:54 -05:00
Irena Rindos beb97ac9f2 SSH Proxy support (#2736)
* initial commit
2023-01-09 13:43:02 -05:00
Hugo 1fb960575f Merge pull request #2613 from hashicorp/llb-target-address
Assign a Network Address to a Target
2023-01-09 18:35:19 +00:00
Irena Rindos a403b3904c initial commit (#2735) 2023-01-09 12:35:13 -05:00
Hugo Vieira f85da3ee2b feat(cmd): Create target using address on boundary dev / database init
Creates a target using an address for boundary dev and when first
init-ing boundary (boundary database init).

It also makes this newly created target the default one
(ttcp_1234567890). The target using host sources is now a secondary
target (ttcp_0987654321).
2023-01-09 15:39:55 +00:00
Damian Debkowski 1d3930a711 feat(handlers): Support address field on a Target 2023-01-09 15:39:55 +00: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
Irena Rindos 9135cc7668 In absence of ingress filter, use directly connected worker (#2757)
* directly connected ingress filtering
2023-01-05 12:09:31 -05:00
Irena Rindos 24bbf57a19 AuthorizeConnection with filters (#2734)
* AuthorizeConnection with filters
2023-01-04 11:24:09 -05:00
Irena Rindos 7db9fc59ce Expose State() *structpb.Struct interface through the metric connection trackers 2022-12-23 08:14:58 -05:00
Irena Rindos 5c73e43912 revert 2712 (#2713) 2022-12-13 14:25:40 -05:00
Irena Rindos a135127524 Move dialingListener setAddresses 2022-12-13 13:29:14 -05:00
Irena Rindos 173e1587d0 Append initial worker upstreams if current upstreams are unresponsive (#2698)
* Append initial worker upstreams if current upstreams are unresponsive
2022-12-12 13:48:28 -05:00
Todd 7a6983c463 Fix wrapped reverse grpc listener (#2702) 2022-12-12 10:27:31 -08:00
Haotian 340cfb0d88 refactor(metric): adds filter function to collector init method (#2695) 2022-12-12 09:12:33 -08:00
Todd a0600138fa Fix wrapped reverse grpc listener (#2687) 2022-12-06 16:17:13 -08:00
Todd b6c0ccc1e8 Refactor proxy handler to separate connection and protocol handling (#2678) 2022-12-06 11:44:00 -08:00
Haotian fbd0a8272b feat(metric): adds accepted/closed connections counters to worker and controller servers (#2668)
* adds counters and changelog entry
2022-12-06 10:13:44 -08:00
Irena Rindos 5b162a4433 add worker version to network graph (#2672)
* add worker version to network graph
2022-12-02 12:36:10 -05:00
Danielle 5f8d292ea1 Inject Custom Response Headers By Status (#2587)
* add custom ResponseWriter struct to inject custom response headers based on status code

* docs

* upgrade listenerutil

* fix config tests

* replace all instances of "data:*" with "data:" to reflect changes to listenerutil

* swapping strings.HasPrefix in favor of mux.Handler for ui request matching

* set ui path as const

* add custom response headers to changelog
2022-12-01 13:15:53 -05:00
Irena Rindos 834a2a88f7 feat(targets): Addition of egress and ingress worker filters (#2654)
* feat(targets): Addition of egress and ingress worker filters
2022-11-30 15:23:37 -05:00
Haotian 2b84013379 Revert " feat(metric): adds accepted/closed connections counters for controller and worker cluster connections (#2656)" for failing a build test (#2660)
This reverts commit 80f72b8511.
2022-11-29 10:22:53 -08:00
Haotian 80f72b8511 feat(metric): adds accepted/closed connections counters for controller and worker cluster connections (#2656)
same contents as PR https://github.com/hashicorp/boundary/pull/2593 but this time actually push to main
2022-11-28 17:35:16 -08: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
Irena Rindos 70e20b5cf5 revert merge llb-multihop-sessions (#2628) 2022-11-17 14:51:29 -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
Irena Rindos 781b03d080 dataplane management (#2624) 2022-11-16 16:22:36 -05:00
Irena Rindos 011a7cf640 Dataplane routing (#2623)
* addition of dataplane routing
2022-11-16 15:34:39 -05:00
Todd 426e6aaa79 Check that the returned resources before referencing them (#2612) 2022-11-14 13:23:56 -08:00
Jeff MitchellandTodd 0c96c6ff6c Split grace period into multiple config values (#2578) (#2603)
Co-authored-by: Todd <github@quaddi.com>
2022-11-10 13:14:57 -05:00
Todd 2a4ce02de6 Disconnect PKI workers from upstreams when they are no longer authorized (#2515) 2022-11-03 14:50:48 -07:00
Irena Rindos b26814a3cc move user variables into globals (#2580)
* move user variables into globals
2022-10-28 15:52:06 -04:00
Irena Rindos 946dab487e enable recovery user to list targets and sessions (#2576)
* enable recovery user to list targets and sessions
2022-10-28 11:17:33 -04:00
Jeff Mitchell cede1aec93 Add initial templating support to Vault credential libraries (#2569) (#2575)
Add initial templating support to Vault credential libraries

This adds support for templating various account and user values into
Vault dynamic credential library POST bodies and GET/POST paths.

It also unifies how parameters are used in grants, with backwards
compatibility.
2022-10-27 09:01:05 -04:00
Hugo Vieira d206635d74 fix(connection): Make bytes up and down a signed 64-bit integer
This fixes a theoretical issue with database interaction. Because the
fields in the database are signed 64-bit integers, it's theoretically
possible to overflow them if we're using unsigned 64-bit integers in the
application code.
2022-10-26 17:44:28 +01:00
Hugo Vieira c81398cbf3 feat(worker): Report bytes up and down on Status updates
With this commit, the Worker now sends BytesUp and BytesDown for each
of the connections it handles to the Controller in the Status request.

The Controller then persists these fields to the database. There is also
a new trigger to prevent bytes_up and bytes_down to change after a
connection has been closed, as the last update to a session_connection
row should be the one that is performed as part of the connection
closure process.
2022-10-26 17:44:22 +01:00
Hugo f023f05c11 feat(worker): Report bytes up/down on Worker connection closure
Introduces data about bytes read and written to the connection close
payload. No changes are required in the Controller because the RPC
messages already contained the required fields. As of this commit,
bytes_up and bytes_down columns in the session_connection table are now
populated when a connection closes.

Refs: #2509
2022-10-26 17:43:05 +01:00
Hugo 1bb80624b8 feat(worker): net.Conn implementation to count Bytes Read and Written
This commit introduces a new net.Conn implementation (countingConn) that
will keep track of bytes read and written for a particular client
connection. This is then implemented into the worker code using
interface composition.

Refs: #2501
2022-10-26 17:43:04 +01:00
Jeff Mitchell b86430c2af Add some common account bits and change over some getOpts -> GetOpts funcs (#2565) (#2566)
This is a precursor to another upcoming PR that will make use of these
changes, but it makes that PR more manageable.
2022-10-25 21:33:31 -04: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
Irena Rindos 2ab6ca6a84 Remove unrelated error from error message (#2558) 2022-10-24 12:23:59 -04:00
Todd 73f7004c74 Add RLocks for all read access to s.connInfoMaps in a session (#2553)
* Add RLocks for all read access to s.connInfoMaps in a session
2022-10-20 14:05:27 -07:00
Jeff Mitchell 37273d7a9c Fix two items: (#2544)
* Randomize order of worker output. This uses the standard
  rand.Shuffle() call; cribbed from
  https://pkg.go.dev/math/rand#example-Shuffle
* Have some error/eventing in the worker status path use the base
  context instead of the status-call-specific context to allow eventing
  after a timeout event
2022-10-18 16:57:07 -04:00
Haotian 3be8b6efed refactor(metric): move common metrics functions out of 'internal' directory (#2536) 2022-10-12 11:04:32 -07:00
Todd 412e7a2418 Add interfaces and error codes for processing downstream router connections (#2511)
* Add interfaces and error codes for processing downstream router connections
2022-10-04 11:07:50 -07:00