Commit Graph
2342 Commits
Author SHA1 Message Date
Timothy Messier 1e1e5a5ff5 doc(perms): Clarify some details in godoc for ListPermissions 2022-09-07 17:53:40 +00:00
Timothy Messier e65f1f32a7 chore(session): Remove repository method that was only used in tests
This unexported method was only used by a single test, and was taking
advantage of its implmentation to populate Connections rather than
Sessions. This repository should only interact with Sessions, since
there is a separate repository for Connections.
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 2fbdcf6ce0 feat(session): Use permissions for limiting list results
The session repository can now be passed an optional set of permissions.
The permissions are used to restrict results from the repository.
Currently this only impacts the List method. This enabled the sessions
service to use a single query to retrieve sessions and replaces the
previous behavior where the session service would first request all
sessions for a given set of scopes, evaluate the permissions, and then
request sessions based on a set of session ids.
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 05b3d2917b feat(perms): Add UserPermissions
This is used to associate a user with a set of permissions which is
necessary for repositories that need honor the OnlySelf aspect of a
Permission.
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
Hugo Vieira 9ee5a9f713 feat(perms): Derive permissions list from user grants 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
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
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 Mitchell ef4000fe08 Update AWS plugin (#2420)
This adds region information to IAM calls in AWS plugin and hopefully
fixes #2233
2022-09-02 14:40:54 -04: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
Jeff Mitchell a1be125f5b Pull in updated AWS plugin to fix #2224 (#2419) 2022-09-01 15:27:24 -04:00
Ryan Cragun 6983bb7d41 enos: don't fail fast in enos integration matrix (#2416)
Disable the fail-fast feature for the matrix strategy. This prevents a
single failure to cascade to all jobs in the matrix. This prevents cases
where other jobs fail before they're able to clean up resources.

Signed-off-by: Ryan Cragun <me@ryan.ec>
2022-09-01 13:16:56 -06: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
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
Zhihe Li a73d85472f chore: Add redirect docs for worker (#2383) 2022-09-01 10:28:07 -04:00
Irena Rindos db21ead31c Vault proxy supporting code (#2415)
* Vault proxy supporting methods
2022-08-31 12:40:35 -04:00
Damian Debkowski 3f70644978 fix(db): update host_plugin_set to set project_id value (#2410) 2022-08-30 16:37:16 -07: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
Haotian 17ddc301a8 feat(cli): add/set/remove worker tags (#2266)
* adds CLI commands for add/set/removing worker tags, and respective tests
* adds StringSliceMapVar Flag to convert a string from the CLI to a map[string][]string value
2022-08-26 13:37:26 -07:00
Irena Rindos 547e7a5970 docs(workers): add documentation for pki worker cred encryption (#2397)
* docs(workers): add documentation for pki worker cred encryption
2022-08-26 13:08:18 -04:00
Jeff Mitchell 1cb287bdbe Update README.md 2022-08-25 14:59:23 -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
Danielle 07a4082aa1 Add SQL Migration 05 From go-kms-wrapping (#2371)
* adding sql migration 05 from go-kms-wrapping

* rename file from 05 to 01 to match boundary standards

* move key rewrap to folder 47
2022-08-25 12:06:43 -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
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 b43e61c8c7 bug(workers): Create worker-led panics on invalid token (#2388)
* Check for error before returning result
2022-08-24 14:43:15 -04:00
Jim b0bc6bd632 refactor: eliminate gorm references in favor of go-dbw (#2386) 2022-08-24 14:11:49 -04:00
Louis Ruch 929a385fdb fix: move 'drop target_all_subtypes' after whx views 2022-08-24 09:33:37 -07:00
Irena Rindos 4aa09242ab Fix dev Docker build (#2380)
* Fix dev Docker build
2022-08-24 09:05:25 -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
Louis Ruch 564affa294 chore: Add 0.10.2 changelog 2022-08-23 15:36:27 -07:00
Josh Brand 8c0efb9715 Enos: add additional guards before authentication (#2382)
* Enos: add additional guards before authentication

Previously, we would see failures when the ALB in front of a
cluster was alive and passing healthchecks, but the database behind
had not been initialized yet.  This adds a check with an unauth'd
call to `auth-methods list` to validate the DB is up before auth.
2022-08-23 14:46:24 -04:00
Damian Debkowski 27e9f775be feat: add initial migration hook 2022-08-22 12:15:20 -07:00
Timothy Messier 79866a287f feat(schema): Add support for migration hooks
This adds the ability to define hooks that will run prior to a schema
migration. The hooks should only be used when a migration would fail due
to data being in an invalid state, likely due to a bug in the previous
schema definition. For example if a column was missing a constraint, and
a new migration is attempting to add the constraint, there might already
be values that violate the new constraint. In such cases, we would want
the user to make a decision to address the data, and need to provide
them with details about what data is problematic in case they want to
manually address the problem. To help the user, if there is a sane way
to address the data, we should provide an option to automatically
"repair" the data, allowing the migration to continue. However, this
still should be an explicit opt-in from the user, and we need to clearly
describe what the repair option would do to the user so they understand
the consequences of opting in.

To accomplish this each migration can be provided a hook that contains a
CheckFunc, RepairFunc, and RepairDescription. These functions must
operate at the point-in-time of the migration immediately preceding the
current migration, as as such they should not use and domain packages or
repositories, instead they should use direct sql with the sql library.
The description is used to explain what the RepairFunc will do.

Hooks should be defined in `internal/db/schema/migrations/oss/oss.go`
and registered with the schema edition.

See the example in `internal/db/schema/manager_example_test.go` for more
details.
2022-08-22 12:15:20 -07:00
Michael Gaffney 1fa79e9aa1 test(db): Add tests for inserts into target_host_set 2022-08-22 12:15:20 -07:00
Michael Gaffney 0512ddb060 test(db): Add tests for inserts into target_credential_library 2022-08-22 12:15:20 -07:00
Damian Debkowski c4aa9a0358 test(sql) add tests to validate project scope for target_static_credential 2022-08-22 12:15:20 -07:00
Jeff Mitchell a56d7aa4d0 Ensure that "null" can only be specified in "set-" commands (#2363)
This allows a check function to be set to determine whether it is
allowed to be set. This also ensures that if null is allowed it is
either the only value or not set.
2022-08-22 14:53:49 -04:00
Jeff Mitchell a7bde08eee Pull in AWS plugin v0.1.1 (#2379)
This adds normalization to the filter field.
2022-08-19 13:37:16 -04:00
Jeff Mitchell 7364d84835 Add mechanism for plugin to normalize attributes (#2376)
* Add mechanism for plugin to normalize attributes

This introduces a new normalization call to the plugin RPC service. If
implemented, the plugin will be given the attributes prior to saving
them in a create/update call, and can perform any normalization needed,
e.g. ensuring that a parameter passed in is represented in a canonical
way. As an example, the CLI allows a user of the AWS plugin to pass in a
string, but canonically it is a string slice, and should be returned
that way as well. Not by chance, this is the exact behavior of the
testing implementation of this function.

This does not update any individual plugin, but rather sets the
controller-side logic up for plugins to support this functionality.
2022-08-18 15:39:30 -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