Commit Graph
381 Commits
Author SHA1 Message Date
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
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
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
Johan Brandhorst-Satzkorn 222a935223 Update grpc-gateway dependency (#2311)
* chore(deps): Update grpc-gateway dependency

This fixes an issue which would allow an attacker to trigger a
(recovered) panic in the gateway handler.

* fix(server): Use cmp.Diff instead of assert.Equal

Testify is not great at handling protobuf types, and
was for some reason returning a diff here when in
reality there is none. Switch to go-cmp for the
comparison to remove the error.
2022-08-11 20:24:14 -04:00
Louis Ruch d01f374490 bug(db): Fix credential purpose migration (#2351)
* bug(db): Fix credential purpose migration
2022-08-11 10:41:48 -07:00
Michael Gaffney a6d9c228aa Merge branch 'mgaffney-greppable-sql' 2022-08-10 18:25:31 -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
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
Michael Gaffney ac6f14a37f style(sql): make migrations more greppable 2022-08-08 18:17:57 -04: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
irenarindos 4908aba546 feat(vault): Add unimplemented worker filter support to OSS 2022-07-25 11:50:27 -04:00
Louis RuchandJeff Mitchell a17e973712 feat(credentials): Refactor credential purposes (#2260)
* feat(credentials): Refactor credential purposes

 * Application credentials have been refactored to Brokered credentials
 * Egress credentials have been refactored to Injected Application
credentials

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2022-07-19 15:16:24 -07:00
Louis Ruch ef5ac07f02 Add ssh_private_key support for Vault libraries and targets (#2263)
* Add support for ssh_private_key credential type in Vault libraries

* Add support for ssh_private_key credential type

* Support jsonpointer for Vault library mapping overrides
2022-07-19 10:31:53 -07:00
Jeff MitchellandLouis Ruch 011e2e7425 Add ssh private key type and add type to static store (#2262)
Co-authored-by: Louis Ruch <louisruch@gmail.com>
2022-07-18 19:16:11 -04:00
Jim 3da78aa7e4 refactor (kms): Update dependency required a small refactor (#2253) 2022-07-11 11:40:03 -04:00
Jeff Malnick 1f66685864 feat: set default connection limit to unlimited (-1) instead of 1 (#2234)
This avoids the confusion behavior of a session terminating as soon
as a single connection using that session is closed.
2022-07-06 12:02:56 -04:00
Timothy Messier fd5d15af27 feat(config): Add database config options for idle connection management (#2176)
This adds two new config options for the `database` stanza:

- `max_idle_connections`
- `max_idle_time`

These correspond to settings for the underlying `sql.DB` instance. They
can be used to have finer control over the controller's database
connection pool. For example this can be used to mitigate the high
connection overhead when connecting to postgres by setting a high
`max_idle_connections` and either setting `max_idle_time` to zero or to
a high duration.

Alternatively, if using a connection pool like pgpool-II or pgbouncer,
`max_idle_connections` can be set to 0.

See:
    https://pkg.go.dev/database/sql#DB.SetMaxIdleConns
    https://pkg.go.dev/database/sql#DB.SetConnMaxIdleTime
    https://www.pgpool.net/mediawiki/index.php/Main_Page
    https://www.pgbouncer.org/
2022-07-05 15:25:55 -04:00
Damian Debkowski 3e9c99c217 refactor(user_password) rename all references of user_password to username_password (#2232) 2022-06-27 14:03:12 -07:00
Jeff Mitchell 396edfca80 Add an extra cleanup task for sessions stuck in canceling state (#2229)
* Add an extra cleanup task for sessions stuck in canceling state

See the comment on the migrations file for details.
2022-06-23 12:25:55 -04:00
Louis Ruch 4cacd0a605 bug(scheduler): Fix controller id length check (#2226)
* bug(scheduler): Fix controller id length check

The job_run table has a foreign key to the server_controller private_id.
While this column is called a prviate_id it does not implement the wt_private_id
postgres domain type, and therefore does not have a minimum length of 10 characters.
2022-06-22 13:20:27 -07:00
Timothy Messier f3c90df300 chore(db): Silence db logs by default for tests
This removes a lot of log clutter from normal test execution with `go
test -v`. There are a number of test that expect no results from the
database or other error cases from the database. The previous default
log level of dbw.Error would cause these cases to generate logs in the
success case, creating noise in the test output.

The new default for tests is dbw.Silent. This can be overriden in two
ways. A test can be updated to pass in the db.WithTestLogLevel option,
which allows for targeting specific tests to include additional output.
This may make sense for tests that normally should not cause errors, but
would report an error if it fails.

Alternatively a new environment variable can be set,
DEFAULT_TEST_LOG_LEVEL. This allows for adjusting the log level without
changing any test file. The environment variable should be set to the
string value of the log level, and is treated as case insensitive, ie:

    export DEFAULT_TEST_LOG_LEVEL="error"
2022-06-21 14:28:02 +00:00
Louis Ruch 9671daf6e0 Revert "refactor(user_passsword) change all references of user_password into username_password (#2189)"
This reverts commit ab58b24142.
2022-06-16 11:11:39 -07:00
Damian Debkowski ab58b24142 refactor(user_passsword) change all references of user_password into username_password (#2189)
* (refactor) change all sql references of user_password to username_password

* refactor(pkg) renamed pkg userpassword to usernamepassword

* refactor(proto) updated protocol buffers to use UsernamePassword

* refactor(code) updated references from UserPassword to UsernamePassword in golang files

* refactor(test) updated unit tests to reference UsernamePassword changes

* refactor(ddtest) updated references in dbtests to use UsernamePassword

* chore(sql-test) fixed spelling issue

* chore(sql) added and updated comments in migartion & tables. fixed indentations

* chore(proto) updated comments to reflect username_password changes

* refactor(tests) updated unit tests to replace user-password with username-password

* refactor(cmd) updated cmd help text to use username

* chore(tests) update test name & comments

* fix(cmd) fixed cmd usage definition for credentials update

* refactor(tests) removed out of scope changes

* fix(sql) incremented sql migration id & updated migration comments
2022-06-16 10:56:46 -07:00
Jeff Mitchell 704d68848c Merge remote-tracking branch 'origin/main' into llb-byow 2022-06-15 16:45:00 -05:00
Jeff Mitchell b0480eb7b3 Move migrations to 32 2022-06-15 16:01:08 -05:00
Todd beecbbb8a2 Upsert creates a new KMS and Updates PKI workers (#2187) 2022-06-15 08:27:08 -07:00
06d0f99536 bug(workersAPI): do not allow nonprintable or uppercase name or desc (#2186)
* Send more info on KMS connect (#2182)

* Update nodeenrollment to v0.1.0

* bug(workersAPI): do not allow nonprintable or uppercase name or desc

* Put checks on create too

* Apply printable check to description in DB

* chore (worker): address PR feedback

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
Co-authored-by: Jim <jlambert@hashicorp.com>
2022-06-14 20:13:02 -04:00
Todd 577d8418cd Make name column immutable for kms workers. (#2190)
errcode 23601 is the error code used by the immutable_column() function.
2022-06-14 15:52:35 -07:00
JimandTodd 9997f1a7bd feature (workers): required schema changes (#2185)
* feature (workers): required schema changes

Changes required for consolidation of worker name, description
and address fields

* fixup! feature (workers): required schema changes

* fixup! feature (workers): required schema changes

* fixup! feature (workers): required schema changes

* Fixing up address constraint.

* last_status_time = now() on insert only if the worker is type = 'kms'

* update last_status_time for pki and kms based on different columns being updated.

* tweaking the constraints on last_status_time and address.

Co-authored-by: Todd <github@quaddi.com>
2022-06-14 14:51:56 -07:00
Louis Ruch 631de0e5e2 chore(changelog): Update changelog 2022-06-14 13:04:35 -07:00
Louis Ruch 4b365db634 feat(target): Add support for static credentials during authorize-session 2022-06-14 13:04:35 -07:00
Louis Ruch 58d9d42a88 feat(session): Add support for session static credentials 2022-06-14 13:01:17 -07:00
Louis Ruch 00dfea1244 feat(target): Add support for static credential as target credential sources 2022-06-14 13:01:17 -07:00
Michael Gaffney b6da1ccac7 feat(db): add static credential store schema 2022-06-14 13:01:17 -07:00
Todd 4b526538af Make server_id in job_run type text since it is nullable. (#2177) 2022-06-13 12:55:05 -07:00
Louis Ruch b6ca61a7f6 refact(cred-libs): Update user_password to username_password (#2154)
* refact(cred-libs): Update user_password to username_password
2022-06-13 09:01:01 -07:00
Jeff Mitchell 5d3facf561 Merge remote-tracking branch 'origin/main' into llb-byow 2022-06-10 19:05:27 -04:00
irenarindos 16d95262a6 feature(worker): add workerKeyId to status 2022-06-10 09:31:22 -04:00
Timothy Messier 32070678dc perf(session): Remove connections from session list endpoint
Including the nested connection information in the session list response
had a negative impact on performance as it created a significant
multiplier on the number of rows that needed to be fetched from the
database.

It was also determined that this information was used by neither the
admin ui nor the desktop client.

Note that nested connection information can still be retrieved via a
read request for a specific session.
2022-06-09 19:28:04 +00:00
Timothy Messier 5b0abe2e27 feat(session): Add migration to delete terminated sessions
There is a new periodic job that will delete terminated sessions that
are older than one hour. However, since until now terminated sessions
were not deleted, the first time the job runs there could be a large
number of sessions that need deleted. This could have a negative impact
on a running cluster. To mitigate the operational risk, this adds a
migration to perform an initial delete while the cluster is offline.
2022-06-09 19:28:04 +00:00
Johan Brandhorst-Satzkorn e7273d65c2 Bump Go version to v1.18.3 (#2158)
* chore: Bump Go version

Go 1.18.3 has some security patches over 1.18.1.

See https://go.dev/doc/devel/release#go1.18.minor

* Fix formatting

This was missed in a recent PR
2022-06-09 11:43:39 -04:00
Gabriel SantosandJohan Brandhorst-Satzkorn 3521c21cd5 fix: Refuse to start if max_open_connections is below 5 (#2097)
* server refuses to start if max_open_connections is below 5

* suggested changes - Update internal/db/db.go

Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>

Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2022-06-09 10:13:55 -04:00
Todd 1e3c941be1 Add active session count to the worker (#2145) 2022-06-07 11:21:39 -07:00