Commit Graph
169 Commits
Author SHA1 Message Date
Irena Rindos 4493dfd527 use prior and current worker auth keys (#2495)
* use prior and current worker auth keys
2022-09-26 11:23:08 -04:00
Jeff Mitchell 74a007bfdd Adapt to new nodeenrollment X25519KeyProducer interface (#2491) 2022-09-23 09:14:17 -04:00
Louis Ruch b7684a857a feat(ssh): Use HostId as HostKeyAlias for connect ssh helper (#2490) 2022-09-22 17:51:30 -07:00
Todd d270513b5a Add error printing when cluster listeners and their consumers error. (#2488) 2022-09-22 14:01:59 -07:00
Irena Rindos bd4f5f3801 update worker auth rotate (#2484) 2022-09-22 13:13:31 -04:00
Todd 06fd086004 Add health endpoint for worker (#2442)
* Return worker process information in the health endpoint.

Experimental:  The worker_info and returned worker_process_info fields are experimental and can change or be removed without notice.

When a user passes in "worker_info=1" or "worker_info=true" and a worker is running the returned json will be returned with a key named "worker_process_info" which value is a json object with information about the worker process.
2022-09-19 11:24:42 -07:00
Irena Rindos d951e1ebc1 Worker graceful shutdown (#2455)
* add graceful shutdown to worker
2022-09-19 09:59:18 -04:00
Damian Debkowski 546c5dc5be feat: static json credentials (#2423) 2022-09-16 15:00:04 -07:00
Irena Rindos 821d8317dc address op state review feedback (#2453)
* address op state review feedback
2022-09-16 09:13:37 -04:00
Jeff Mitchell 53b5e532d5 Remove deprecated methods/fields on targets (#2393) 2022-09-15 09:20:08 -04:00
Jeff Mitchell 37fb9815ce Add session endpoint test for #2448 (#2450) 2022-09-13 20:29:58 -04:00
Louis Ruch 50490d71ae chore(targets): Improve help and errors around ssh targets (#2445) 2022-09-13 13:05:36 -07:00
Louis Ruch 5812a42ba3 feat(scheduler): set intervals from config (#2443) 2022-09-13 10:01:49 -07:00
Irena Rindos fc0ead73e6 feat(workers): worker operational state (#2427)
* feat(workers): worker operational state
2022-09-12 16:10:03 -04:00
Hugo Vieira 8ab9ffbcac refact(cmd): Encapsulate some functionality on Command and Server
This commit extracts 3 separate pieces of functionality into their own
function/method:

- Extracts the database opening with the intention to have a function
  that performs all that functionality but returns the created database
  object rather than setting it to the Server structure.
- Extracts database validation logic, to provide a common code path for
  upcoming functionality.
- Expose schema manager on the Command struct as well as providing
  common functions to acquire shared lock/close.
2022-09-12 17:55:32 +01:00
Timothy Messier 047a66e87d fix(worker): Improper reload when running as controller and worker (#2438)
In cases where the server was started with both a controller and worker
stanza, the reload of the config was not properly setting the initial
upstream value on the new config. In this case the value is derived from
other config values and not necessarily set directly.

This now properly initializes the new config so that initial upstream is
set in the same manner as the first load.

Blame: 5d0cdf680f
2022-09-12 09:37:13 -04:00
Irena Rindos 18dff62b7b Merge BYOW GA branch to main (#2398)
* feat(workers): Add ability to read and reinitialize cert authority (#2312)

* feat(workers): Return Release Version on worker list and read (#2377)

* feat(cli): Read and reinitialize worker certificate authority (#2387)
2022-09-08 13:19:21 -04:00
Hugo Vieira bf1486f75e refact(target): Add context to RepositoryFactory constructor
`errors.New` requires a context, so I've made that available from the
Controller, and updated all `NewDeprecated` functions to `New` while
I was at it
2022-09-07 17:53:40 +00:00
Hugo Vieira bf263fbd7d perf(target): Use new Permissions object to determine resource access
Using the new Permissions object, we can build a list of the level of
access a user should have based on the grants they've been given,
meaining we don't need to fetch all resources from the database to then
remove the ones the user shouldn't be able to see.

This commit also removes some unused options in `ListTargets`
for the sake of simplicity.
2022-09-07 17:53:40 +00:00
Hugo Vieira 63196ee4ca feat(target): Implement new WithPermissions option
Also changes the Target RepositoryFactory to allow for passing options
at construction time.
2022-09-07 17:53:40 +00:00
Hugo Vieira 224f8d2d4e refact(controller): Move Target Repository Factory to the target package 2022-09-07 17:53:40 +00:00
Timothy Messier eb61ac6304 refact(session): Add context to session factory
This adds a context to the session.RepositoryFactory, allowing
errors.NewDeprecated to be replaced with errors.New. It also removes the
common.SessionRepoFactory, instead packages just directly import from
the session package.
2022-09-07 17:53:40 +00:00
Timothy Messier febf0b9984 refact(controller): Use session repo factory that takes options 2022-09-07 17:53:40 +00:00
Timothy Messier 68568828e6 perf(sessions): Use session repository with permissions
This builds on previous performance improvements to the list behavior by
reducing the number of queries against the database and the amount of
data transfered in order to retrieve a list of sessions. Previously, a
query was performed to retrieve a tuple of `(session_id, scope_id,
user_id)` for the requested scope, including all child scopes if the
request was recursive. These tuples were evaluated against the
requesting user's grants to identify the sessions that they were
authorized to list.  In the case of clusters with a large number of
sessions, this would result in a large amount of data needing to be
transfered for sessions that would not be used.  Then a second query
would be used to retrieve the full session information for the session
ids that were authorized.

This changes the list behavior to evaluate a set of permissions from
the requesting user's grants, use these permissions when constructing a
session repository, and retrieve the list of sessions the user is
authorized to list in a signle query.

Ref:
    d741034829
    32070678dc
2022-09-07 17:53:39 +00:00
Timothy Messier e4bb847ad1 feat(auth): Expose ACL from VerifyResults 2022-09-07 17:49:01 +00:00
Timothy Messier 39fedd843c test(targets): Remove auth.DisabledAuthTestContext from tests
Disabling the auth was resulting in some unrealistic tests setup and
expectations. It also makes it difficult to refactor any behavior in the
authn/authz flow since this option can bypass most of it.
2022-09-07 17:49:01 +00:00
Timothy Messier 02cef3d8a8 test(sessions): Remove auth.DisabledAuthTestContext from tests
Disabling the auth was resulting in some unrealistic tests setup and
expectations. It also makes it difficult to refactor any behavior in the
authn/authz flow since this option can bypass most of it.
2022-09-07 17:49:01 +00:00
Hugo Vieira ccb17df01a feat(auth): Get all authorised scope info for a given list request 2022-09-07 17:49:01 +00:00
HaotianandTodd 5c715478e4 feat(workers): Add metrics for worker server-side grpc connections, refactor repeated code into common location (#2367)
* feat(workers): added latencies histogram for server side multihop workers

* refactor(daemon): combine common grpc metric functions into daemon/internal/metric

Co-authored-by: Todd <github@quaddi.com>
2022-09-06 13:40:52 -07:00
Louis Ruch d7c4c648ec bug(vault): Correctly handle credential stores with expired tokens (#2399)
* bug(vault): Correctly handle credential stores with expired tokens

Boundary makes use of a database view to perform CRUD operations on
Vault credential stores and libraries. This view did not include
credential stores with tokens that have expired in Vault, causing
errors when attempting to perform any action against them.
2022-09-06 07:50:15 -07:00
Jeff MitchellandIrena Rindos 01fb949d0b Add controller-led worker auth flow (#2413)
This adds an action to the API that allows pulling out an activation
token that can be given to a worker in its config (directly or via env
or file). The worker can pass this along with its normal request in
place of its normal nonce and the server will automatically accept it.

Co-authored-by: Irena Rindos <irenarindos@users.noreply.github.com>
2022-09-02 14:32:41 -04:00
Timothy Messier 5d0cdf680f feat(worker): Support reloading of initial upstreams on SIGHUP (#2417)
On a SIGHUP, if the worker's `initial_upstreams` config option has
changed, it will use the new values as the address to send its status.
Any previously discovered upstream addresses from previous status
requests are dropped. Once a successful status request is made to the
new addresses, the worker will resume its normal behavior of using the
addresses from the response to the status request.

This allows a worker to be deployed in a more stable way in a dynamic
environment where controller IPs could change. In particular this helps
with a case where all controllers are replaced with new controllers
running on new IPs.

To illustrate with an example, suppose there is an instance group of
controllers instances. And there are worker instances that have their
config rendered from consul-template that sets `initial_upstreams` to
the IPs of the controller instances. If all controller instances are
restarted or replaced at the same time and assigned new IPs, a new
config will be rendered for the worker. Previously the only way for the
worker to use the new value would be for the worker process to be
restarted. Otherwise the worker would only know about the previous IPs
and would fail to connect to the new controllers. However, a restart
would mean any active sessions and session connections on the worker
instance would be terminated. With this update, consul-template can send
a SIGHUP to the worker, the worker will connect to the new controllers
and resume normal status reporting, allowing the sessions and session
connections to remain.

The same principles would apply for other examples of dynamic
environments such as nomad and kubernetes.

See:
    https://github.com/hashicorp/consul-template
    https://www.nomadproject.io/docs/job-specification/template
2022-09-01 14:13:42 -04:00
Irena Rindos db21ead31c Vault proxy supporting code (#2415)
* Vault proxy supporting methods
2022-08-31 12:40:35 -04:00
Jeff Mitchell 9b271d7dd8 Fix error about unimplemented HcpbWorkers call (#2361)
Although there is a compile time check on the type, it will always
succeed due to the Unimplemented embedding requirement.

As a result, this PR also changes Unimplemented calls to Unsafe calls,
which were added later "for those that prefer their code to break"; the
comments on these state:

// UnsafeXServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to XServiceServer will
// result in compilation errors.

See https://github.com/grpc/grpc-go/issues/4500#issuecomment-852597871
for some more context.

I think we're fine with compilation errors though; we own both the
server and client side of things and generally are going to add new
methods only when we intend to also add them on the client side.
Notably, what the comment does not indicate is that it will break at
runtime; already it should return a suitable (404 or 405) error if the
client requests a method that does not exist.
2022-08-30 14:22:10 -04:00
Irena Rindos b4b95e0f0e refactor(vault): add context and remove deprecated errors (#2396)
* refact(vault): add context and remove deprecated errors
2022-08-25 14:37:22 -04:00
Johan Brandhorst-Satzkorn aef9073fa6 Upgrade to Go 1.19 (#2347) 2022-08-25 12:12:24 -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
Renato Costa ec3d2ef360 Fix incorrect use of loop variable in parallel tests (#2389)
This fixes occurences of a loop variable being captured in parallel
tests. With the previous code, only the last test case is actually
exercised. To work around this problem, we create a local copy of the
range variable before the parallel test, as suggested in the
documentation for the `testing` package:

https://pkg.go.dev/testing#hdr-Subtests_and_Sub_benchmarks

Issues were found automatically using the `loopvarcapture` linter.
2022-08-24 16:46:29 -04:00
Irena Rindos dde0c35f23 Update request data in session manager (#2369)
* bug(session): Update request data in session manager
2022-08-24 09:03:29 -04:00
Damian Debkowski 27e9f775be feat: add initial migration hook 2022-08-22 12:15:20 -07:00
Jim 2818bb65cd feature (downstreams): Add hooks for optional downstream workers/router (#2359)
This includes the required interfaces, factories, error codes, etc
2022-08-12 11:08:25 -04:00
Jim 7aa7deafa3 chore: update go-dbw dependencies (#2298)
* chore: update go-dbw dependencies

This update included an update of the upstream gorm dependency.

In the latest update, gorm appears to have become more sensitive when
a slice is passed into operations.  The ptr to slice must now
be a ptr to slice of ptrs.  This change required an update to how
boundary handles slices of PrincipalRole, which now must return a ptr
to PrincipalRole.   There were also some tests that needed to be
updated because of this change.

* fixup! chore: update go-dbw dependencies
2022-08-10 17:20:06 -04:00
Jeff Mitchell 7df1331e93 Update configutil/pluginutil deps (#2346)
Fixes #2343
2022-08-10 16:32:02 -04:00
Louis Ruch 7fafadd70b db: Add credential_sha256 to session_credentials (#2339)
* db: Add credential_sha256 to session_credentials
2022-08-08 18:54:42 -07:00
02dd28f587 Add support for SSH private key passphrases (#2331)
This adds support for encrypted SSH keys via passphrase.

Co-authored-by: Louis Ruch <louisruch@gmail.com>
Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
2022-08-08 15:15:03 -04:00
Jeff Mitchell 07bca9dd66 Ensure initial upstreams is empty before hcpb worker listing (#2334)
The intention of the code was to have one-hop-away workers list KMS
workers to get initial upstreams, and have other workers continue using
what was in their config file. However, nothing stops people from having
initial_upstreams but _also_ adding a cluster ID in their config file,
in which case we'd always run this check and replace the config-set
initial upstreams. So, ensure the config-set initial upstreams is also
len zero.
2022-08-08 12:39:34 -04:00
Jeff Mitchell 090b2b28f8 Clean up some dev config kms code (#2321)
* Clean up some dev config kms code

Although it didn't matter in the combined state, the KMS for auth
storage was not actually being set properly if only a worker was being
instantiated.
2022-08-05 12:12:07 -04:00
Jeff Mitchell 8800ec9c94 Reorganize logic to allow a poison pill (#2317) 2022-08-03 19:29:17 -04:00
Jeff Mitchell 4bd249d347 Fix some missing net.JoinHostPort calls (#2305) 2022-07-29 12:08:37 -04:00
Damian Debkowski c25b9285c0 fix(test) uncomment ro tests for cred update (#2301) 2022-07-28 11:58:45 -07:00