Commit Graph
2382 Commits
Author SHA1 Message Date
Timothy Messier f28bcd4aa7 chore(cli): Run bats tests against boundary dev in CI
Several of these tests are being skipped in the enos
run. This seems to be due to differences in the setup that is performed.
When these tests were run manually, `boundary dev` was used which
performs some setup of resources automatically. However since enos uses
a non-dev controller, a similar setup is performed via the enos modules.

Until the discrepancies between the setup can be investigated, this adds
a separate CI job to run the tests against `boundary dev`. These tests
are all passing, without any being skipped. This test suite can still be
useful even if the enos version is fixed, since this test suite will run
much faster, and therefore identify failures sooner.
2022-09-16 15:54:55 +00:00
Timothy Messier c41e31381d test(cli): Fix session read and cancellation test 2022-09-16 15:54:10 +00:00
Kevin Wang 4f69fcedbb fix(website/Makefile): mount /../internal/gen (#2461) 2022-09-16 11:18:30 -04:00
Irena Rindos 821d8317dc address op state review feedback (#2453)
* address op state review feedback
2022-09-16 09:13:37 -04:00
Louis Ruch c73a13aa3e scheduler: log details when starting scheduler (#2459) 2022-09-15 11:44:45 -07:00
Irena Rindos e588623ebd docs(vault): add Vault worker filter documentation (#2404)
* docs(vault): add Vault worker filter documentation
2022-09-15 13:18:22 -04:00
06370867c7 website: content updates for developer (#2426)
* chore(website/nav-data): sup to badge
```
            "badge": {
              "text": "OSS Only",
              "type": "outlined",
              "color": "neutral"
            }
```

* update previews to render developer UI

* Apply suggestions from code review

* update redirects

Co-authored-by: Kevin Wang <kwangsan@gmail.com>
Co-authored-by: HashiBot <62622282+hashibot-web@users.noreply.github.com>
2022-09-15 10:27:10 -04:00
Jeff Mitchell 53b5e532d5 Remove deprecated methods/fields on targets (#2393) 2022-09-15 09:20:08 -04:00
Dharini Jeeva 54cdaaada8 add worker tags redirect (#2447) 2022-09-14 12:48:39 -07:00
Louis Ruch 506fdfa5c3 cli(ssh): Do not print private key if consumed (#2451) 2022-09-14 12:46:34 -07:00
Damian Debkowski 5dfabe5f90 fix: show warning log when token will expire before it can be renewed (#2446) 2022-09-14 09:35:37 -07:00
Jeff Mitchell 37fb9815ce Add session endpoint test for #2448 (#2450) 2022-09-13 20:29:58 -04:00
Yoko Hyakuna fa619b0910 Address reported bugs (#2449) 2022-09-13 19:48:06 -04:00
Timothy Messier 2b994f3005 fix(perms): Properly resolve "only self" for permissions (#2448)
When generating permissions from the grants, if a single grant was
limited to the set of "self" actions, the permission would be marked as
only self, even if additional grants were given for non-self actions.
This would result in the generated permissions being more limiting then
they should be based on the grants. This only impacts the sessions list
endpoint. It would result in users that have been granted access to list
other user's sessions to be unable to see these results in the list
results.
2022-09-13 19:46:52 -04:00
Louis Ruch 50490d71ae chore(targets): Improve help and errors around ssh targets (#2445) 2022-09-13 13:05:36 -07:00
Damian Debkowski 2db6bee3e2 fix: return an error for vault tokens that will expire before the scheduler can run (#2444) 2022-09-13 10:43:49 -07:00
Louis Ruch b908cfb860 chore: prep for next release 2022-09-13 10:16:48 -07:00
Louis Ruch 5812a42ba3 feat(scheduler): set intervals from config (#2443) 2022-09-13 10:01:49 -07:00
Timothy Messier d0a61b29b8 chore: Add missing items to changelog (#2440)
Add items for SIGHUP database reload and performance improvements.
2022-09-13 07:55:39 -04:00
Irena Rindos fc0ead73e6 feat(workers): worker operational state (#2427)
* feat(workers): worker operational state
2022-09-12 16:10:03 -04:00
Hugo f3f0c55d91 Merge pull request #2422 from hashicorp/hugoamvieira-controller-dbswap
If the database url is updated on Boundary's config and then a SIGHUP
triggered, we now connect to the new database, ensure it's OK to use
and use that one going forwards instead.

This allows a controller to be deployed in a more dynamic infrastructure
where, for example, database credentials could change, without having
to restart the controller.

This operation is done atomically to prevent errors and inconsistency. 
A timeout is present so that if the object is swapped after the 
existing one has been looked up it isn't immediately invalidated. 
The timeout is a maximum; a ticker once a second that looks at
stats to determine how many database connections are still in use 
and then closes the driver as soon as none are in use.
2022-09-12 18:05:11 +01:00
Jeff Mitchell 9002930d65 Adapt shared lock skip logic to dbswap branch (#2437) 2022-09-12 17:55:32 +01:00
Hugo VieiraandJeff Mitchell bed6e1a0ff feat(server): Reload database on SIGHUP
If the database url is updated on Boundary's config and then a SIGHUP
triggered, we now connect to the new database, ensure it's OK to use
and use that one going forwards instead.

This allows a controller to be deployed in a more dynamic infrastructure
where, for example, database credentials could change, without having
to restart the controller. In this case only a database url config
change and a SIGHUP signal to all controllers would be required.

This uses an atomic.Pointer to store wrapped DB objects. This allows
atomically swapping to the new object. A timeout is introduced so that
if the object is swapped after the existing one has been looked up it
isn't immediately invalidated. The timeout is a maximum; a ticker once a
second that looks at stats to determine how many database connections
are still in use and then closes the driver as soon as none are in use.

This could be done with mutexes to avoid checking stats in a loop, but
that carries its own risk: if a write lock is attempted to be acquired
while a query is holding a read lock, the write lock will block, and any
subsequent read locks will also block since write locks take priority.
As a result, if a query is long-running or timing out, all other queries
in the system will become blocked. Our default user request timeout is
90 seconds and some jobs have no timeout at all, so this is not a purely
theoretical concern, even if it's unlikely.

Refs: #2435
Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2022-09-12 17:55:32 +01: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
Hugo Vieira 621f8a9ff2 fix(schema): Database connection not cleanly closed
This commit introduces closing the Schema Manager's underlying driver
connection. We were only releasing the shared lock but not actually
cleaning up the db connection and relied on the fact that the process
would exit to do that for us.
2022-09-12 17:55:32 +01:00
Jeff Mitchell 8e969787f9 Update CHANGELOG.md
Fix 0.10 -> 0.10.0.
2022-09-12 12:32:01 -04: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
Todd 0b942f4493 Only clear tags in set-worker-tags when "null" is set as the value of the -tag flag. (#2434) 2022-09-08 11:15:03 -07: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
Irena Rindos cee5ff7599 Minor documentation fixes for controller-led (#2432)
* Minor documentation fixes
2022-09-08 10:15:47 -04:00
Johan Brandhorst-Satzkorn f362bf0e1f chore: Upgrade to Go 1.19.1 (#2429) 2022-09-07 17:29:13 -04:00
Jeff Mitchell fdb60f5b2d Update comment around undocumented config flag 2022-09-07 16:44:23 -04:00
Jeff Mitchell 730131c105 Add test 2022-09-07 16:32:18 -04:00
Jeff Mitchell 16c9e9b592 Add ability to skip shared lock acquisition 2022-09-07 16:28:07 -04:00
Louis Ruch cb8a541b02 chore: prep for next release 2022-09-07 11:38:55 -07:00
Timothy Messier 0d29942db9 Merge branch 'llb-list-performance' pull request #2342 from hashicorp/llb-list-performance
Improve response time for list requests for targets and sessions. This
refactors the behavior between the target and session services and how
they interact with the domain layer. Now the service is able to evaluate
the set of permissions from the requesting user's grants, use these
permissions when constructing the corresponding repository, and retrieve
the list of the resource the user is authorized to list in a single
query.

This reduces the round trips to the database and greatly reduces the
amount of data received from the database.

This impacts commands (in particular when `-recursive` is used):

    boundary targets list
    boundary sessions list

And the corresponding API endpoints of:

    GET /v1/targets
    GET /v1/sessions

There is no change to the data returned.

See:
    68568828e6
    bf263fbd7d
2022-09-07 18:17:29 +00: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 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