Commit Graph
100 Commits
Author SHA1 Message Date
Timothy Messier 603642f271 fix(session): List performance with large number of session connections (#3288)
As part of the performance improvements for listing sessions for v0.9.0,
the view used to retrieve sessions for listing was updated to no longer
include a join on session_connection. However, a later migration that
was adding additional columns to this view inadvertently re-added the
join and session_connection columns. This resulted in requests to list
sessions performing this join, and returning additional rows for each
connection in a session. The application would ignore this additional
data, since it is no longer returned via the API. This would be
particularly impactful in cases where there are a large number of
connections per session, as this would greatly increase the amount of
data returned by the database.

This fix removes the session_connection join from this view, which
should restore the original performance improvements even in cases where
there is a large number of session connections per session.

See: https://github.com/hashicorp/boundary/pull/2160
Ref: 32070678dc
Fixes: 1e3c941be1

(cherry picked from commit 7aef341682e65b42c1b919e03936bdf81e26e87c)
2023-06-06 17:45:53 +00:00
Timothy Messier 876f9bb07f fix(session): List performance with large number of session connections
As part of the performance improvements for listing sessions for v0.9.0,
the view used to retrieve sessions for listing was updated to no longer
include a join on session_connection. However, a later migration that
was adding additional columns to this view inadvertently re-added the
join and session_connection columns. This resulted in requests to list
sessions performing this join, and returning additional rows for each
connection in a session. The application would ignore this additional
data, since it is no longer returned via the API. This would be
particularly impactful in cases where there are a large number of
connections per session, as this would greatly increase the amount of
data returned by the database.

This fix removes the session_connection join from this view, which
should restore the original performance improvements even in cases where
there is a large number of session connections per session.

See: https://github.com/hashicorp/boundary/pull/2160
Ref: 32070678dc
Fixes: 1e3c941be1
2023-06-06 17:45:30 +00:00
Timothy Messier 7e094d824f feat(bsr/convert): Remove asciicast minimum window size (#3287)
This removes the minimum on width and height, instead it will just used
the largest width, height seen as the initial size for the asciicast.
This also provides the ability to still set a minimum via options to
convert.ToAsciicast if the caller has a known minimum size. Also note
that in cases where there is no size information, ie if there was no pty
request, this will still pick a default size of 80x24.
2023-06-06 12:26:46 -04:00
Timothy Messier 75ef443ae1 chore: Update api and sdk tags 2023-06-01 15:11:57 +00:00
Timothy Messier 84b96f89a7 chore: Bump version 2023-05-31 16:01:03 +00:00
Timothy Messier 61a37ef4a4 fix(schema): Add missing endpoint column to session recording view 2023-05-31 15:53:16 +00:00
Timothy Messier f64f03ed46 fix(targets): Support authorize session request with target name (#3252)
For requests to the target authorize session endpoint we support passing
a target name instead of an id. This means that `req.GetId()` might not
be the target's public id. Since the first thing authorize session does
includes retrieving the target as part of the authorization checks, this
subtype check can leverage the public id of the target instead of using
the request.

Fixes: 6178dd516e
2023-05-31 11:25:03 -04:00
Timothy Messier c2da88d2a5 test(cmd/config): Fix test compilation error
Refs: 9ae2bdfae
2023-05-31 12:47:20 +00:00
Timothy Messier 29b9a508a3 chore(lint): Ignore warning about deprecated field
This is being explicitly tested until it is removed, so this silences
the linter for this specific case.
2023-05-31 12:18:24 +00:00
Timothy Messier cdf18b6369 test(cli/targets): Add test case for default client port 2023-05-31 12:18:24 +00:00
Timothy Messier 9f2c83f3b0 refact(bsr): Rename const to denote when interpolation is needed 2023-05-31 12:18:23 +00:00
Timothy Messier b88b4cce75 feat(bsr/ssh): Add file transfer direction to channel summary
When an SSH channel is used for a file transfer, the summary will report
the detected direction of the file transfer as either an upload or
download, relative to the end client.
2023-05-31 12:18:23 +00:00
Timothy Messier 78ea1a9f3a refact(bsr): Use JSON for session meta and summary data
The session metadata is provided all at once when a new bsr is opened.
While the session recording metadata records metadata about a recording
while the recording is happening, notably it records each time a new
connection occurs.

The nested structure of the session metadata does not lend itself to the
append-only syntax of the recording meta file. In addition we do not
want to mix different kinds of metadata together. Thus the session
metadata is now written to a separate file in the BSR, and is written as
JSON which better handles the nested structure and allows for simpler
encoding/decoding.

Similarly the summary files are intended to be written to as containers
close and have been switched to JSON.
2023-05-31 12:18:23 +00:00
Timothy Messier f53d65eacd refact(sql): Rename migrations to avoid number conflicts 2023-05-31 12:18:23 +00:00
Timothy Messier b9de6cf00b fixup:(bsr): Correctly reference subcontainers when opening
This is a fixup for 60785b5a8
2023-05-31 12:18:21 +00:00
Timothy Messier 738a6c6472 feat(bsr/convert): Implement ToAsciicast
This adds support for converting a channel in a SSH BSR to an asciicast.
2023-05-31 12:18:21 +00:00
Timothy Messier 9227fcd879 feat(bsr/convert): Add logic to convert ssh channel to asciicast 2023-05-31 12:18:21 +00:00
Timothy Messier ed6882a457 feat(bsr/convert): Add asciicast package
This provides a new internal package for constructing and serializing an
asciicast in the v2 asciicast file fromat.

See: https://github.com/asciinema/asciinema/blob/develop/doc/asciicast-v2.md
2023-05-31 12:18:21 +00:00
Timothy Messier 916a919bf0 feat(bsr): Remove ascii format of protocol
This was originally introduced to ensure that the meta files only
included ascii characters. However, this makes reading the protocol from
meta file less reliable since it does not exactly match the protocol
string. Instead protocol strings will be recorded in the meta files as
is. Generally protocol strings should include readable characters.

This also updates the ssh.Protocol to be 4 readable characters.
2023-05-31 12:18:21 +00:00
Timothy Messier 4112c4e8fe feat(bsr): Add methods for opening ChunkScanners for data files 2023-05-31 12:18:21 +00:00
Timothy Messier e37fa39c95 feat(bsr/fstest): Add localfs implementation
This adds another test storage.FS implemenation. This can be used to
write/read containers and files from a local filesystem via calls to the
os pacakge.
2023-05-31 12:18:21 +00:00
Timothy Messier 713d961152 feat(bsr/fstest): Add test TempFile implementation 2023-05-31 12:18:21 +00:00
Timothy Messier b4ce802572 refact(bsr/convert): Use new storage.TempFile interface
This changes the ToAscinema function to take a storage.TempFile instead
of a storage.FS. It was noticed that when this was being used a
storage.FS was being created just prior to calling this just so that it
could then create a temporary file. It seemed to make more sense to just
pass the temporary file in, instead of needing to expand the storage.FS
interface.

This also renames this method to align with the file format that the
returned io.Reader will contain.
2023-05-31 12:18:21 +00:00
Timothy Messier e29939ce41 feat(storage): Define interface for creating temporary files
This provides a new type for a temporary file and a method on a
RecordingStorage to create temporary files. Temporary files will get
removed when closed.
2023-05-31 12:18:21 +00:00
Timothy Messier 46e1752283 feat(bsr/fstest): Support read mode
This updates the fstest implementation of a storage.FS to support
opening sub containers and files in read-only mode.

Now when calling `SubContainer`:

- If using `storage.WithCreateFile`, an error is returned if the
  container already exists.
- If not using `storage.WithCreateFile` and error is returned if the
  container does *not* exist.

When calling `OpenFile`:

- on a container that was created with `storage.ReadOnly`, an error is
  returned if attempting to open the file wth `storage.ReadWrite`.
- with `storage.WithCreateFile`, an existing file is replaced with a new
  empty file, (ie "truncated").
- without `storage.WithCreateFile`, an error is returned if the file
  does not exist.
2023-05-31 12:18:20 +00:00
Timothy Messier e9c7e373e9 feat(bsr/fstest): Implement Open method 2023-05-31 12:18:20 +00:00
Timothy Messier 82989fd123 feat(storage): Stub out Open interface method 2023-05-31 12:18:20 +00:00
Timothy Messier 5d0a9b706e feat(bsr): Add ChunkScanner
The scanner can be used to read any BSR data file. When creating a new
scanner, it will first verify the BSR magic string. Individual Chunks
can then be read back by calling Scan. The scanner will compute a
sha256sum while it is reading chunks. If the scanner was created using
the WithSha256Sum option, it will compare the computed checksum with the
one provided via the option once the scanner encounters an end chunk
(DONE) or an io.EOF error from the reader. If the checksums do not
match, and error will be returned from Scan. The current sha256sum can
be returned from the scanner using the Sum method.

There is also a convenience function, ChunkWalk that can be used to call
a function on each Chunk returned by a scanner.
2023-05-31 12:18:20 +00:00
Timothy Messier f983a05a3e feat(bsr/ssh): Support decoding chunks
This adds a function for decoding all of the SSH Chunk types and
registers the function with the chunk types so that the bsr.ChunkDecode
can be used to decode SSH Chunks.
2023-05-31 12:18:20 +00:00
Timothy Messier fe870fc989 feat(bsr): Add ChunkDecoder
A ChunkDecoder can be used to BSR Chunks. Each call to Decode will read
the next chunk from the decoder's io.Reader. It handles decompressing
any compressed chunk data, and verifying the CRCs of each chunk.
2023-05-31 12:18:20 +00:00
Timothy Messier 648842f031 feat(bsr/checksum): Add function to load SHA256SUM
This provides a Sha256Sums type to store the information from a
SHA256SUM file in memory for easy lookup of the sums of files. It can be
used when checking the checksums of individual files without needing to
go back to disk.
2023-05-31 12:18:19 +00:00
Timothy Messier 18eca382c6 feat(globals): Add prefixes for recording resources 2023-05-31 12:18:16 +00:00
Timothy Messier 29c739e8b8 feat(bsr): Add function for generating a channel id 2023-05-31 12:18:16 +00:00
Timothy Messier 21f6be9ab5 refact(sql): Move migrations to avoid number conflict 2023-05-31 12:18:15 +00:00
Timothy Messier 51e6e64d09 fix(bsr/checksum): Close after calling Stat 2023-05-31 12:18:12 +00:00
Timothy Messier 96f3c71cda test(bsr): Properly handle closed state for test fs implementation
The test implementation will now correctly mimic a real fs's Close
behavior. It will prevent reads and writes to a closed file or
container.
2023-05-31 12:18:12 +00:00
Timothy Messier 26bd86fb07 feat(bsr): Add chunk encoder 2023-05-31 12:18:11 +00:00
Timothy MessierandIrena Rindos 2a31ddd881 feat(bsr): Define container and the required fs interfaces
Co-authored-by: Irena Rindos <irenarindos@users.noreply.github.com>
2023-05-31 12:18:11 +00:00
Timothy Messier 9302705d1b chore: Update go-kms-wrapping dep
This is necessary to get the SigInfoSigner.
2023-05-31 12:18:10 +00:00
Timothy Messier 897b70f090 feat(storage): Make Option fields exported
This makes it possible to have external packages implement the
storage.FS, storage.Container, and storage.File interfaces and correctly
inspect the various options.
2023-05-31 12:18:10 +00:00
Timothy Messier 397a697731 feat(bsr): Define stubs for meta structures
These are used to provide the metadata about a session or connection
when writing a BSR and will be written to the corresponding .meta files
within a BSR.
2023-05-31 12:18:09 +00:00
Timothy Messier d15d2e3bc0 feat(bsr): Define required interface needed by storage 2023-05-31 12:18:09 +00:00
Timothy Messier 658bb27eeb feat(bsr): Define initial interfaces and types 2023-05-31 12:18:08 +00:00
Timothy Messier d792cf4487 test(vault): Increase threshold for period assertion (#3216)
This allows for a greater delta between the period returned by vault and
they expected value to account for some delay due to load on the test
runners.
2023-05-11 08:46:59 -04:00
Timothy Messier 7f7a5ac9c3 ci(test): Remove matrix for running tests per package (#3200)
The original motivation for the matrix was to mitigate an issue some
tests failing that used a vault docker container. When the tests ran in
a single step, these tests would almost always fail. By splitting the
tests per package, the failure rate of these tests was around 20%.

GitHub was able to identify the cause. There was an issue with localhost
resolution that causes requests to the vault containers to sometimes
fail, resulting in the kinds of failures that were seen. Note that the
same issue was not seen when accessing the test postgres database that
was running in a container, since the test code connects via 127.0.0.1,
while the vault container used localhost. This commit includes the
recommended fix so that localhost name resolution works as expected on
the GitHub hosted runners.

It also removes the test matrix since it is no longer needed as a work
around. In addition it seems advisable to remove the matrix given the
recent discovery that some tests were not running with the matrix. While
this was fixed, removing the matrix reduces the risk of any future
mistakes from the test splitting.

This also seems to result in a faster pipeline execution time. The
overhead to determine the matrix values, wait for a runner to be
available, and restore from the cache seems to add up to a longer
overall execution time.

Eliminating the matrix can also help with another type of failure seen.
Sometimes restoring from the cache fails. By eliminating the test
matrix, it will greatly reduce the number of cache restoring done by the
workflow, which will reduce the chances of an issue restoring from
cache.

The only remaining benefit from the matrix, was that if there was a
transient test failure, a re-run of only the failed jobs would be
relatively quick (depending on which package had the failure), while
without the matrix the entire test suite will need to be re-run.

See: https://github.com/hashicorp/boundary/pull/3199
Refs:
    86214a85e1
    e04438b7f8
2023-05-03 14:18:13 -04:00
Timothy Messier 743bbf88ac fix(cliui): Download correct artifact (#3134)
This was missed on the previous fix. It now references the correct
artifact name now that this is back to running as part of the build
workflow.

Blame: 181f0f1806
2023-03-30 10:28:27 -04:00
Timothy Messier 181f0f1806 fix(cliui): Call test-cli-ui workflow from build (#3126)
It seems the workflow_run trigger only calls the workflow as it is on
the default branch (ie `main`). This would make it difficult to make
changes to this workflow and set of tests.

Blame: e76b3b9511
2023-03-29 20:27:09 -04:00
Timothy Messier 87b5d1b21c Merge pull request #3044 from hashicorp/tmessi-ci-actionlint
This performs some final clean up of github actions as part of the
migration away from CircleCI
2023-03-29 16:05:50 -04:00
Timothy Messier 1806151392 ci(build): Set permissions for workflow 2023-03-29 18:39:03 +00:00
Timothy Messier e4fbc0281a chore(ci): Update and pin actions steps 2023-03-29 18:39:01 +00:00
Timothy Messier a7c11846d6 lint(ci): Address linter issue for workflow files 2023-03-29 18:38:50 +00:00
Timothy Messier e76b3b9511 ci(cliui): Move to separate workflow
This will run the cli ui (bats) tests in a separate workflow from the
build workflow. This takes advantage of the newer workflow_run event to
trigger the tests after the build has completed, so that the artifacts
from the build step can still be used.
2023-03-29 18:38:50 +00:00
Timothy Messier a241ca452c ci: Add actionlint workflow 2023-03-29 18:38:50 +00:00
Timothy Messier e4c656ae5d Merge pull request #3114 from hashicorp/tmessi-schema-diff-fix 2023-03-27 11:04:40 -04:00
Timothy Messier 9d2758368c doc(schema-diff): Add documentation on schema-diff script
This also will include a link to this documentation when leaving a
comment on a pull request.
2023-03-27 14:27:54 +00:00
Timothy Messier 04a6c310ee fix(schema-diff): Include foreign key constraints in diff
With the change to report changes to constraints instead of all of the
post-data section, foreign key constraints where no longer captured in
the diff. This now extracts the foreign key constraints and generates a
diff of them between versions.

Blame: b6d58d0c42
2023-03-27 14:27:54 +00:00
Timothy Messier b6d58d0c42 ci(schema-diff): Generate one file per constraint (#3082)
This yeilds a better diff when constraints are changed.
2023-03-14 12:57:07 -04:00
Timothy Messier 23f9a7774b chore(globals): Add missing copywrite header (#3083) 2023-03-14 12:08:36 -04:00
Timothy Messier 000fc7c0e0 ci: Remove CircleCI configuration (#3065)
CI is now performed via Github Actions. Some notable Github Action
workflows that replace the CircleCI jobs are:

- test: replaces CCI build, test-api, test-sdk
- test-sql: replaces CCI test-sql
- make-gen-delta: replaces CCI make-gen-delta

See:
    https://github.com/hashicorp/boundary/actions/workflows/test.yml
    https://github.com/hashicorp/boundary/actions/workflows/test-sql.yml
    https://github.com/hashicorp/boundary/actions/workflows/make-gen-delta.yml
    https://docs.github.com/en/actions
    https://cli.github.com/manual/gh_run
2023-03-08 14:23:33 -05:00
Timothy MessierandHugo Vieira b00d888387 ci(schema-diff): Add script to generate diff of database schema (#2924)
The script should be given a base branch to compare against, if not set
it defaults to main. The script will apply the schema migrations for
both the base branch and the current commit and generate dumps that are
then compared to create a diff. The dumps are left in a temporary
directory so that they can be compared using a users preferred diff tool.

For example, generate the dumps and diff against main

    ./scripts/schema-diff.sh main

Examine the diff to database functions using delta:

    delta .schema-diff/funcs_$(git rev-parse main) .schema-diff/funcs_$(git rev-parse HEAD)

This also adds a github action that runs the script on pull-requests
that contain schema changes and reports the diffs as a comment on the
pull-request.

Co-authored-by: Hugo Vieira <hugoamvieira@users.noreply.github.com>
2023-03-03 16:21:33 -05:00
Timothy Messier 236d7ca872 ci: Additional githubaction configuration (#3034)
- Pin action versions
- Dependabot to notify about action updates
- Update codeowners
2023-03-01 08:00:46 -05:00
Timothy Messier 5e0957eb24 ci(test): Use docker mirror (#3018) 2023-02-24 14:49:16 -05:00
Timothy Messier d7b567e843 ci(trigger-merge-to-downstream): Fix typo in workflow 2023-02-24 13:54:48 +00:00
Timothy Messier 39e1cd7dcf chore(ci): Add downstream merge trigger to github action (#3014) 2023-02-24 08:36:47 -05:00
Timothy Messier 18b0bcb395 chore(ci): Revert some permission settings
These workflows seemed to break with these permission changes.
2023-02-23 21:14:53 +00:00
Timothy Messier 2a47e9ddf8 ci: Set permissions in workflows (#3011) 2023-02-23 15:50:26 -05:00
86214a85e1 ci: Run go tests in github action (#2997)
This runs the make targets:

- make test
- make test-api
- make test-sdk

The go tests in the main module are split by package and run in parallel
in a matrix build with GOMAXPROCS=1. This is done primarily to work
around an issue that is only seen on the github runners.  When running
at a higher GOMAXPROCS tests that use vault instances in docker
containers start to intermitently fail with errors from vault, usually
either a 400, 403, or TLS error. It is not clear what the cause of this
is, since the same tests run fine on self hosted runners and on
CircleCI.

Co-authored-by: Sarah Thompson <sthompson@hashicorp.com>
Co-authored-by: Daniel Kimsey <daniel.kimsey@hashicorp.com>
2023-02-23 14:58:40 -05:00
Timothy Messier b69d1c2e2e fix(cli): Fallback parsing of un-typed credentials (#2989)
The `boundary connect` subcommands attempt to parse the credentials to
use for brokering. This allows the subcommands to insert the credentials
automatically into the process called by the subcommand, i.e. `ssh` or
`psql`. There is some fallback logic to try a best attempt at parsing
the credential in cases where a credential type has not be set on the
credential source.

The bug was introduced with the recent change to the vault credential
library subtype being renamed from `vault` to `vault-generic`. This
fallback logic would only run if the credential source type was "vault"
or "static", so if the vault credential library was created without
specifying a credential-type, the credential would not be parsed and
automatically passed to the sub-process.

This fix removes the additional check on the credential source's type,
instead it will attempt to parse the credential, relying just on the
structure of the credential.

This also fixes a similar bug in the table output of secrets when using
`boundary connect` without a subcommand. The parsing of the credentials
for display in the table was only running for `vault` or `static`.

Blame: db42eafd7a
2023-02-21 16:38:42 -05:00
Timothy Messier af1b8d2f02 ci: Remove deprecated output from make-gen-delta 2023-02-16 21:22:30 +00:00
Timothy Messier 876b25fead ci: Use variable for runner (#2981) 2023-02-16 16:17:04 -05:00
Timothy Messier 96ab199562 ci: Run make-gen-detla in github action (#2980) 2023-02-16 14:49:47 -05:00
Timothy Messier 5c19dba3c9 ci(sqltest): Add github action workflow for sql tests (#2977) 2023-02-16 14:37:48 -05:00
Timothy Messier e25b0e7888 fix(credentiallibraries): Fallback logic to support 0.11.x cli (#2910) 2023-02-06 11:00:34 -05:00
Timothy Messier 718e183a1e fix(credentiallibraries): Correctly populate attrs for vault-generic (#2901) 2023-02-03 14:21:08 -05:00
Timothy Messier ded39259e3 Merge pull request #2887 from hashicorp/tmessi-fix-cli-ui-tests
fix(cli): Status code on api error
2023-02-03 12:21:18 -05:00
Timothy Messier f9a2f44f5b test(cli): Add tests for vault-ssh-certificate credential library
This adds tests for updating specific fields of the credential library.
2023-02-03 17:00:34 +00:00
Timothy Messier e66ea15fef fix(cli): Status code on api error
When using the json output of the cli (`-format=json`), a successful
call to the controller API would place the HTTP status code in the JSON
as `status_code`. However, if there was an error from the API the status
code would be placed in the JSON as `status`. In order to be consistent,
this adds a `status_code` field to the error response case. For
backwards compatibility it still populates `status` in the error case.

This inconsistency was missed partially due to a bug in the CLI tests.
The assertion on status code was not valid and would always be
successful. Thus this also fixes the assertions and tests.
2023-02-03 17:00:34 +00:00
Timothy Messier 99a8875d3e feat(version): Determine binary version during initalization
This ensures that checks for features should work, and bails early if
that is not the case, since if this fails the binary is essentially
broken. This also simplifies code that performs these checks, ie instead
of:

    binaryVersion, err := version.GetReleaseVersion()
    if err != nil {
      // handle error? panic?
    }
    if version.SupportsFeature(binaryVersion, version.FeatureA) {
      // code for FeatureA
    } else {
      // without FeatureA
    }

Implementations can do:

    if version.SupportsFeature(version.Binary, version.FeatureA) {
      // code for FeatureA
    } else {
      // without FeatureA
    }
2023-02-03 17:00:33 +00:00
Timothy Messier db42eafd7a Merge pull request #2860 from hashicorp/llb-vault-ssh-cert-injection
Add vault ssh certificate credential library

This adds a new credential library type, `vault-ssh-certificate`, which
can be used with vault's ssh secret engine to generate certificates to
use as credentials for ssh. This new credential library can be created
using:

    boundary credential-libraries create vault-ssh-certificate

See the help output for a full list of the options supported.

This also renames the `vault` credential library subtype to
`vault-generic`. The previous subtype of `vault` will continue to work,
thus the following commands are equivalent:

    boundary credential-libraries create vault-generic
    boundary credential-libraries create vault

See: https://developer.hashicorp.com/vault/docs/secrets/ssh
2023-02-02 12:44:20 -05:00
Timothy Messier 862481960d chore(CHANGELOG): Add items for vault ssh certificate cred library 2023-02-02 17:43:17 +00:00
Timothy Messier 32dd7f07d0 fix(vault): Only persist revokable credentials
When issuing credentials from vault credential libraries, only persist
the vault credential if it is revokable. A credential that is revokable
has a valid lease id that can be used to revoke the lease in vault. If
the credential is not revokable it is also not renewable since renewing
also requires a lease id.

See: https://developer.hashicorp.com/vault/docs/concepts/lease
2023-02-02 17:43:17 +00:00
Timothy Messier 12a53bbfa9 feat(target): Allow vault ssh cert library as credential source
This allows the new vault ssh certificate credential library to be used
as an injected application credential source.
2023-02-02 17:43:17 +00:00
Timothy Messier 1aaaf4af1d feat(controller): Translate ssh certificate credentials for worker 2023-02-02 17:43:17 +00:00
Timothy Messier 6a41bf1237 feat(wh): Support vault ssh certificate credentials
This expands the wh_credential_dimension to include fields for the new
vault ssh certificate credential library.
2023-02-02 17:43:17 +00:00
Timothy Messier 45b15fab8c ci: Start vault for cli ui tests 2023-02-02 17:43:17 +00:00
Timothy Messier 89a55632ba feat(cli): Add vault ssh certificate credential library 2023-02-02 17:43:17 +00:00
Timothy Messier e2248c1360 fix(wh): Associate session fact with credential dimensions (#2787)
The wh_upsert_credential_group function was incorrectly attempting to
update the session connection fact table. There are a couple problems
with this:

1. At the time that this runs, there would be no session connection facts
   for this session.
2. This function is meant to update the session fact table, there is a
   separate function that associates the credential group with the
   session connection facts.

This also fixes another bug that was causing expired rows of the
credential dimension to be included in the group membership. And finally
it fixes a typo in the function name.
2023-01-13 11:24:32 -05:00
Timothy Messier f39833ebad chore: Add downstream merge triggers (#2524)
Trigger a downstream merge. This requires that the DOWNSTREAM_SLUG
environment variable is set in CircleCI. This will trigger downstream
merges for main and all release branches.
2022-10-06 13:38:27 -04:00
Timothy MessierandJeff Mitchell d896f37493 Support reading multiple configuration files(#2504)
feat(config): Support multiple files

This updates the three subcommands that take a `-config` flag to
to support multiple config files via a repeated `-config` flag.
It updates the following subcommands:

- `server`
- `database init`
- `database migrate`

Note that the multiple file support only works if all config files are
HCL, not JSON. Also note that the config files are concatenated
together. There is no attempt to merge config files, so having the same
stanza in multiple files can yield unexpected results, with only one of
the stanzas being used.

When used with these limitations understood, this provides a way to take
different actions for different kinds of dynamic configuration changes.
An example would be when using consul-template to render the
configuration files for boundary. With the multi file support
consul-template can render one config file for the controller stanza,
and provide boundary with a dynamic database credential via vault. Then
when the credential is rotated, consul-template can send boundary a
SIGHUP to switch to the new credential without a restart. A separate
template could be used to render a config for a stanza that does not
support SIGHUP, such as the events stanza that gets its values via
consul's KV. If these values change, consul-template can restart
boundary so the new configuration is used.

Co-authored-by: Timothy Messier <tim.messier@gmail.com>
Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2022-09-29 09:01:33 -04:00
Timothy Messier 01206eb586 chore(build): Allow for downloading pre-built admin ui assets (#2475)
The admin ui assets are built via a github workflow and published as
github a artifact. The artifact can be downloaded, avoiding the need to
build the assets again locally, and eliminating the need for front-end
build tools like yarn and npm.

This updates the `build-ui` target to use a new script that will attempt
to download the pre-built assets. Note that this script requires that
the `gh` cli is installed since an authenticated request is necessary to
download the workflow artifacts. If the artifact cannot be downloaded
either due to the lack of `gh` or because the artifact cannot be found,
it will fallback to using `git clone` (and will require yarn to build
the assets).

See:
    https://cli.github.com/
    https://docs.github.com/en/rest/actions/artifacts
    https://github.com/actions/upload-artifact/issues/51
2022-09-20 11:14:02 -04:00
Timothy Messier a2ef14283b fix(org): Address bug that prevented deleting an org (#2465)
The schema changes introduced in 0.10.2 introduced a bug where an org
could not be deleted if there was a session for an org scoped user. It
would result in an error like:

    scope.(Service).deleteFromRepo: unable to delete scope: \
        iam.(Repository).DeleteScope: failed for o_VkNy46KwfS: \
        iam.(Repository).delete: db.DoTx: iam.(Repository).delete: \
        db.Delete: insert or update on table "session" violates foreign key constraint "target_fkey": integrity violation: error #1003

A worker around would be to first delete all projects in the org, then
finally delete the org.

This fix adds a regression test to the sqltests and updates several
constraints on the session table to be deferrable. Since the org delete
is a single transaction, this allows all of the necessary resources to
be deleted before attempting to enforce these constrains.

See: https://www.postgresql.org/docs/current/sql-set-constraints.html
Blame: 3a28ab614
2022-09-19 09:47:52 -04:00
Timothy Messier f19184ba72 Merge pull request #2462 from hashicorp/tmessi-cli-ui-dev
chore(cli): Run bats tests against boundary dev in CI
2022-09-16 15:25:22 -04:00
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
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
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
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
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
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