Commit Graph
103 Commits
Author SHA1 Message Date
Jeff Mitchell 8322916fb4 Remove all deprecated Err/Wrap/E calls (#3286) 2023-06-14 21:55:24 -04:00
Jim d4e537c88d chore: updgrade pgx direct deps to v5 (#3258) 2023-06-01 08:59:38 -04: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
Jim 63a2b62b85 chore (deps): update GKW and protobuf; and run "make gen" (#3111) 2023-03-22 14:32:52 -04:00
Jeff Mitchell b76b24a4ad Move prefixes for many packages into the globals package (#3069)
This is a prerequisite for some enhancements to grant validation
2023-03-10 15:06:39 -05:00
Timothy Messier 5e0957eb24 ci(test): Use docker mirror (#3018) 2023-02-24 14:49:16 -05:00
Johan Brandhorst-Satzkorn 3c29308673 chore: Add license headers to all files 2023-02-03 15:54:27 -08: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
Danielle 3a78a74571 feat(vault): Support Issuing SSH Cert Credentials
Allows the new credential library type to be pulled from the db and used
for issuing ssh certificate type credentials. The ssh cert library
interfaces with vault's ssh secrets engine to either issu certificates
directly from vault, or to generate them within boundary and have vault
sign them as a certificate authority for authentication.

See:
  https://developer.hashicorp.com/vault/api-docs/secret/ssh#sign-ssh-key
  https://developer.hashicorp.com/vault/api-docs/secret/ssh#generate-certificate-and-key
2023-02-02 17:43:16 +00:00
HaotianandTimothy Messier 823b8cdfc6 feat(vault): Add CRUDL methods for ssh certificate cred library (#2765)
This defines a new credential library type for ssh certificates.
It adds new repository methods to support CRUDL of the new ssh
certificate credential library.

Co-authored-by: Timothy Messier <tim.messier@gmail.com>
2023-02-02 17:43:16 +00:00
Danielle 7833dd73c0 refact(vault): Create issuingCredentialLibrary Interface
Allows for new issuing credential library implementations in the future.
Moved db and decrypt logic to privateCredentialLibraryAllTypes from
issueCredentialLibrary.

This also removes sessionId from retrieveCredential, it was not needed
and removing allows retrieveCredential to be reused for credentials
issued outside current workflow.
2023-02-02 17:43:16 +00:00
Danielle 46037cf85a Add Staticcheck to Build Pipeline (#2421)
Run staticcheck linters on pull requests
2022-12-13 12:07:18 -05:00
Jim 38b12394fd refactor (kms): add GetWrapperer for RewrapFn parameter (#2701)
* refactor (kms): add GetWrapperer for RewrapFn parameter

* tests (kms): add MockWrapper and MockGetWrapperer

Make it a bit easier to write unhappy path tests which depend on
a Wrapper or GetWrapperer
2022-12-13 05:38:14 -05:00
edd323b73a Key Rotation/Destruction (#2477) (#2607)
* Key Rotation/Destruction (#2477)

* fix: Correct kms.CreateKeys comment

This method does not return anything.

* feat(kms): Add new ListKeys method

The new ListKeys method wraps the underlying KMS wrapper,
returning all the keys in the scope specified.

* feat(scopes): Add new scope actions for key management

Adds list-keys, rotate-keys and revoke-keys actions for scopes.

* feat(scopes): Add ListKeys API endpoint

This new endpoint lists all keys in a scope

* feat(api): Add ListKeys to Scopes client

This has to be a custom function because it is a custom action
and doesn't map well to any of the existing templates, or
generalises well in a way that would make it reasonable
to create a new template.

* feat(cli): Add new scopes list-keys command

* add RotateKeys function to the kms repository

* Add Rotate Keys Endpoint to Scopes Api (#2360)

* add rotate keys endpoint

* add tests for RotateKeys endpoint

* remove that one comment I forgot about

* addressing more PR comments

* Add Rotate Keys CLI Command (#2395)

* add cli command and client

* add bats tests

* fix some info text and pr comments

* write a new rotate keys description

* Add Missing DEK Foreign Keys (#2408)

* add missing fks

* mark key as nullable in gorm

* update tests to use a new wrapper with a real key_id

* fix formatting in test and add keys for auth_token test

* replace key values

* revert postgres_40_01_test.go

* style: reformat sql for readability

* refactor: change type of key_id columns to kms_private_id

* Store key_id and scope_id with oplog entries, re-type columns referencing data key version (#2431)

* fix(db): Correct types of data key version referencers

* fix(oplog): Fix missing error handling

* feat(oplog): Store key_id and scope_id with oplog entries

This migration truncates all existing oplog entries, as
migrating existing data would have been complex and
likely unnecessary.

* Update view references

* Always delete oplog entries when dropping keys

* Fix rebase issues

* Fix sql tests

* Add schema for new kms destruction jobs (#2479)

* feat: Add schema for new kms destruction jobs

The schema lets us manage destruction jobs per-table
while providing a guarantee that only one run is running
at a time.

* Apply suggestions from code review

Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>

* Fix table reference and tests

Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>

* update domain, api, and cli to all include key versions in outputs (#2472)

* update domain, api, and cli to all include key versions in outputs

* fix go sum

* add migration to fix immutable error

* fix final test issue as well as make gen issue

* rebase and fix

* address johan pr comments

* make gen, didn't realize comments were included

* update migrations based on new migration 55 file 03

* Move migrations to 56

* feat: Add key version rewrapping function registry (#2478)

The new RegisterTableRewrapFn can be used by a domain
to register a callback to use when rewrapping data in a
specific table name.

* feat(kms): Add scopeId to RewrapFn (#2539)

This makes it much easier for rewrap functions to look up
the correct wrapper and limit the number of rows searched.

* Update Root Cert Proto Definition (#2542)

* update root cert proto definition to properly identify public_key as the table primary key

* add the test fix as well

* Rewrap Functions for Encrypted Tables (#2532)

* add oidc rewrap

* add argon2 config rewrap

* add auth token rewrapping

* add worker auth cert rewrapping

* check the err

* add username password credential rewrapping

* add ssh private key credential rewrapping

* add vault client certificate rewrap function

* add host catalog secret rewrap function

* cleanup a little

* add host vault token rewrap function

* add session credential rewrap function

* add session rewrap function

* add worker auth rewrap function

* update test to include full assert gamut

* add session rewrap function TEST

* bring all tests up to current standards, make more readable, and include full assert gamut

* rework all rewrap functions to utilize scope id

* update comments, queries, sql refs, etc, in response to PR comments

* forgot a comment

* remove hmac updates and fix a couple comments again

* Rewrapping Registered Tables Test (#2555)

* add the registered table test as well as the two missing rewrap functions

* address pr comments, add db r/w conversions, cmp.diff, sql comment, remove (now) faulty immutable test

* Add ability to list key version destruction jobs, recurring jobs and destroying key versions (#2498)

* feat(kms): Add ability to list data key version destruction jobs

* feat(scopes): Add ListKeyVersionDestructionJobs

* feat(cli): Add list-key-version-destruction-jobs

* feat(kms): Add recurring job that performs table rewrapping

The new recurring job runs for each job table with a registered
rewrapping callback. It attempts to become the running run and
start its rewrapping, gracefully handling sudden interruptions
by resuming it's work if it finds evidence of sudden interruption.

* feat(kms): Add recurring job for destroying key versions

The new job monitors the database for data key version destruction
jobs that have finished rewrapping all its data, performing
the final data key version revocation.

* feat(kms): Add DestroyKeyVersion

DestroyKeyVersion immediately destroys a key version
if it is a root key version or a data key version
which encrypts no data. If the data key version
encrypts data which needs to be rewrapped, it
queues an asynchronous job to complete the rewrapping
operation.

* feat(scopes): Add DestroyKeyVersion API endpoint

* feat(cli): Add scopes destroy-key-version CLI command

* Ensure all secret updates include key ID (#2556)

* feat(all): Ensure all secret updates include key ID

When updating a secret, it is paramount that the key ID
is also updated, as it is the only means we have of ensuring
that we only destroy keys once there is no more data
associated with the key.

* Remove fix to session repository for now

This breaks the current private key derivation method

* add new encrypt/decrypt funcs and made necessary proto changes (#2557)

* add new encrypt/decrypt funcs and made necessary proto changes

* address all PR comments

* fix test panic

* add param checking to rewraps

* fix(schema): Correctly organize migrations again

* Review comments part 1

* Review comments part 2

* Review comments part 3

* Store cert private key, encrypt tofu token (#2583)

* fix(session): store cert private key, encrypt tofu token

Previously, we would derive a session certificate private key from
the session key used in each project, and not store the key. We
would also encrypt the tofu token with the database key but not
store a reference to this key in the database.

This change fixes this by replacing our key derivation with a key
generation step, and instead store the generated key, encrypted,
in the database. We also ensure that any new tofu tokens are
encrypted with the same key.

To handle existing sessions, we lazily rewrite the sessions whenever
a user lists them. There is a minor risk that a user could end up
destroying the database key that encrypts the tofu token before
that session has been rewrapped, but this is going to be rare and
temporary.

* feat(session): Allow the random source for secrets to be configured

* Review comments

* Minor fixes

* More minor fixes

* More small fixes

Co-authored-by: Danielle Miu <dani.miu@hashicorp.com>
Co-authored-by: Danielle <29378233+DanielleMiu@users.noreply.github.com>
Co-authored-by: Michael Gaffney <mike@gaffney.cc>
Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>

* fix(session): Unset session key ID when scope is deleted

Unsetting the key ID allows the session to live beyond the lifetime of
the scope, while allowing the scope to cascade delete its keys.

* fix(migrations): Rewrite migration 56 tests

These tests can no longer use the normal test helpers
as they try to use the new oplog table structure, so we
have to manually write all the interactions.

* fix(migrations): Rename migration 58 file name

This was the name used in the release branch, update
it to the new migration number.

* fix(e2e): Add some comments and debug to kms tests

* fix(session): Handle empty project and user IDs in read

When a project or user is deleted, the session is automatically
canceled and the respective field on the session is unset.
LookupSession did not handle this case gracefully, and would
error on decryption in this state. Skip decrypting sessions that
do not have either a user or project to avoid this error. The
decrypted values are not used for a canceled session.

* Fix worker test

* Increase test timeout

Co-authored-by: Danielle Miu <dani.miu@hashicorp.com>
Co-authored-by: Danielle <29378233+DanielleMiu@users.noreply.github.com>
Co-authored-by: Michael Gaffney <mike@gaffney.cc>
Co-authored-by: Michael Gaffney <mgaffney@users.noreply.github.com>
2022-11-16 18:17:28 -05:00
Jeff Mitchell cede1aec93 Add initial templating support to Vault credential libraries (#2569) (#2575)
Add initial templating support to Vault credential libraries

This adds support for templating various account and user values into
Vault dynamic credential library POST bodies and GET/POST paths.

It also unifies how parameters are used in grants, with backwards
compatibility.
2022-10-27 09:01:05 -04:00
Johan Brandhorst-Satzkorn f57454b6b9 Rewrite interface{} to any (#2535)
* chore: Rewrite interface{} to any

* Add ignore revs
2022-10-25 19:29:38 -04:00
Louis Ruch b78d83e242 log(vault): Log formatted duration instead of nanoseconds (#2481) 2022-09-21 12:04:29 -07:00
Damian Debkowski 546c5dc5be feat: static json credentials (#2423) 2022-09-16 15:00:04 -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
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
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
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
Irena Rindos db21ead31c Vault proxy supporting code (#2415)
* Vault proxy supporting methods
2022-08-31 12:40:35 -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
Jim b0bc6bd632 refactor: eliminate gorm references in favor of go-dbw (#2386) 2022-08-24 14:11:49 -04:00
Damian Debkowski 27e9f775be feat: add initial migration hook 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 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
Damian Debkowski 2cbe65597b fix(creds) fix unit test for ssh private key creds (#2297) 2022-07-27 16:31:10 -07:00
Louis Ruch 47739566bc bug(vault): Fix token len check (#2291) 2022-07-25 11:08:06 -07: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
Jeff Mitchell 271cc8f781 Add ssh private key to CLI (#2265) 2022-07-19 16:58:03 -04: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
Jeff Mitchell 8c56a5648d Migrate plugin host/set/catalog prefixes to typed (#2256)
* Migrate plugin host/set/catalog prefixes to typed

* Add credential store typing too
2022-07-15 13:09: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
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
Louis Ruch 68eb6e2bed chore(targets): remove deprecated credential libraries on target resources (#1533) 2022-06-15 08:56:24 -07:00
Louis Ruch c14fe05036 feat(credential): Add support for retrieving static credentials 2022-06-14 13:04:28 -07:00
Louis Ruch 58d546cdd4 feat(credential): Add static credential store and username_password credential 2022-06-14 13:01:17 -07:00
Haotian 40ba275759 feat(worker): add 'initial_upstreams' field to worker config to prepare to replace 'controllers' field. Update worker config description on website. 2022-06-13 15:45:03 -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
Jim 70c5da1048 feature (workers): add repository CreateWorker(...) (#2105) 2022-05-26 13:32:21 -04:00
Louis Ruch 6f4cee88bf fix(vault_store): Correctly return expected errors (#2081)
* fix(vault_store): Correctly return errors
2022-05-17 12:20:01 -07:00
Todd b58dada40d Move the server daemons into their own package (#2061)
* Move the server daemons into their own package

With this change the internal/server package now is dedicated to the server domain (workers and controllers) and not to the server daemons.
The hope is that this will make it easier to keep the daemons decoupled from the representation of the servers in the database.
2022-05-09 12:45:10 -07:00