Commit Graph
81 Commits
Author SHA1 Message Date
Johan Brandhorst-Satzkorn 3c29308673 chore: Add license headers to all files 2023-02-03 15:54:27 -08:00
Johan Brandhorst-Satzkorn dcb499ed4f chore: Add copywrite Makefile target
The new copywrite target can be used to add any
missing license headers.
2023-02-03 15:54:27 -08:00
Johan Brandhorst-Satzkorn 501761a564 chore: Add changelog entry for job_run fix (#2897) 2023-02-03 14:57:33 -05:00
Johan Brandhorst-Satzkorn 55259029f1 Add job run cleaner (#2866)
* chore: remove duplicate import

* feat: Add job run cleaner

The new job cleans job runs older than a configured interval.
Configure the job to clean jobs older than 1 minute.
2023-01-31 20:41:33 -05:00
Johan Brandhorst-Satzkorn e8588620f3 Add Heimdall summary (#2830)
Used by the CORE SRE team Heimdall product to give
quick overview of all the HashiCorp repositories.
Initially this just adds some very basic information
about this repository. Could be expanded if we
expand the use of Heimdall.
2023-01-24 12:29:45 -05:00
Johan Brandhorst-SatzkornandJeff Mitchell 61c90c5623 Add grant parsing fuzz test (#2534)
* testing(perms): Add Parse fuzz test

I ran this for a few minutes and it didn't discover anything catastrophic.

* Add roundtrip tests

* Fix invalid unicode parsing, empty output fields

* Do the unicode conversion once on input

* Remove incorrect fix for empty output fields

* Allow empty output_fields

This is the same behavior as output_fields=,

* Add tests back, make JSON behaviour consistent

* Rework the output fields mechanism to fix some bugs such as properly handling no fields

* Change signature of Fields

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2023-01-06 18:27:19 -05:00
Johan Brandhorst-Satzkorn ef6f94f496 chore: Remove unused CI job (#2764) 2023-01-06 14:45:02 -05:00
Johan Brandhorst-Satzkorn 240278cbf1 fix(docs): Use "root" to reference the root key (#2700)
The "root" identifier is how we identify the root key in configuration,
so it is the phrase we should use in this documentation.
2022-12-12 11:24:58 -05:00
Johan Brandhorst-Satzkorn 5d48b10123 Upgrade Go (#2699)
* fix(ci): Make goinstall read from .go-version

* Upgrade Go version

Go version 1.19.4 contains a security fix that affects all HTTP/2
servers.
2022-12-09 15:58:40 -05:00
Johan Brandhorst-Satzkorn eb113b5c9e fix(db): Reorder migrations (#2688)
Migration numbers need to be consistent between version upgrades.
The migrations for the key lifecycle management were merged
into v0.11.1 as number 56, but are currently 58 in main.
This reorders them down to 56, fixing an issue when
migrating from 0.11.1 to main.
2022-12-08 13:40:14 -05:00
Johan Brandhorst-Satzkorn 6d25b35b4e Add KMS rotation/destruction feature to the changelog and docs (#2600)
* Add initial changelog entry

* feat(docs): Add initial stab at docs for KMS rotation/destruction

* fixup! Add initial changelog entry

* Review comments
2022-12-01 13:32:35 -05:00
Johan Brandhorst-SatzkornandDan Heath df02501dcc Create new "previous-root" key purpose for root key migrations (#2639) (#2648)
* Update go-kms-wrapping dependency

* Apply changes suggested by Jeff

* Fix listener test

* Add note about config fix to CHANGELOG

* Review comments

Co-authored-by: Dan Heath <76443935+Dan-Heath@users.noreply.github.com>

Co-authored-by: Dan Heath <76443935+Dan-Heath@users.noreply.github.com>
2022-11-24 20:07:37 -05:00
Johan Brandhorst-Satzkorn 8908dccf6d Forward port some release fixes (#2631)
* fix(worker): Verify contents of loaded session (#2629)

* fix(worker): Verify contents of loaded session

Previously, it was possible for an empty private key to be used
when the session had no user or project associated with it.
The new checks guarantee that we will fail gracefully in these
cases.

* Check against len instead of nil

* Add CHANGELOG

* fix(session): Always invoke all parts of session cancel trigger

The session cancelation trigger would not set the key_id to null
appropriately if another one of the fields on the session was
already null, since that case statement would be matched first.
The new structure matches all statements, in case any of them have
special logic (such as in the project case).
2022-11-17 18:21:20 -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
Johan Brandhorst-Satzkorn a216c701ee Silence events from DB errors (#2601) (#2602)
If callers want errors to create events, they can do so
by wrapping the error. Sometimes we don't want db
errors to be events, and before this there was no way
to supress them.
2022-11-09 17:04:05 -05: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
Johan Brandhorst-Satzkorn da9adb0c02 feat: Build docker dev images for specified platform (#2493)
Previously, building this target on an ARM machine would
produce an image with a amd64 binary inside an arm
OS.
2022-09-26 11:39:13 -04:00
Johan Brandhorst-SatzkornandTimothy Messier 5dbcda512a Fix enos bats test errors (#2468)
* test(cli): Remove skips in CI for cli tests

* fix(enos): Fix enos bats tests

The tests still sometimes suffer from timing issues,
but I was able to run a successful run (setup, run, destroy)
of the tests from my machine at least once.

There were 2 issues:

- Some tests in groups.bats were hardcoding the default user id
- The default grants for a user in a project were missing
   the permission to connect to a target. We now add this
   explicitly.

Co-authored-by: Timothy Messier <tim.messier@gmail.com>
2022-09-20 14:39:28 -04:00
Johan Brandhorst-SatzkornandYoko Hyakuna 5dc7e7f55c doc: Add link to generated API docs on API page (#2460)
* doc: Add link to generated API docs on API page

This makes it easier to find the generated API docs from the API
description page.

* Update website/content/docs/api-clients/api.mdx

Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>

Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>
2022-09-16 12:02:15 -04:00
Johan Brandhorst-Satzkorn f362bf0e1f chore: Upgrade to Go 1.19.1 (#2429) 2022-09-07 17:29:13 -04: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
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
Johan Brandhorst-Satzkorn aef9073fa6 Upgrade to Go 1.19 (#2347) 2022-08-25 12:12:24 -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
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
Johan Brandhorst-Satzkorn 91e6857631 fix: Use correct yaml (#2373)
Didn't notice this until it failed on main
2022-08-17 20:27:26 -04:00
Johan Brandhorst-Satzkorn b6445adff0 feat: Stop enos jobs from failing CI pipelines (#2372)
Enos jobs are still a bit unstable, we should use them as
advisory for now. When they have gained more stability,
we can let them fail pipelines again.
2022-08-17 19:56:06 -04:00
Johan Brandhorst-Satzkorn e8b2104a80 fix: Update Dockerfile to use new PRODUCT_VERSION arg (#2370)
This is necessary since the merge of https://github.com/hashicorp/actions-docker-build/pull/25
2022-08-17 16:02:29 -04: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
Johan Brandhorst-Satzkorn 2e3ec967f6 fix: Respect context when retrying (#2285)
Respect the cancellation of the context being passed in,
preventing us from retrying events that are doomed to fail.
2022-07-25 12:31:17 -04:00
Johan Brandhorst-Satzkorn 0315c999fe fix: support building docker images on M1 (#2250)
Now developers on the M1 can use
DEV_DOCKER_GOARCH=arm64 make docker-build-dev
2022-07-11 11:48:07 -04:00
Johan Brandhorst-Satzkorn a537491cbc chore: Update changelog with plugin fix (#2240) 2022-06-29 13:23:31 -04:00
Johan Brandhorst-Satzkorn ed406e2853 fix: Upgrade configutil dependency (#2239)
Fixes https://discuss.hashicorp.com/t/latest-boundary-versions-ignoring-plugins-execution-dir/41281

See: https://github.com/hashicorp/go-secure-stdlib/commit/bf6d78ef5b727b83b2f8f41b473eb9764b446df4
2022-06-28 15:12:36 -04:00
Johan Brandhorst-Satzkorn 77bc45ae62 chore: Split proto breaking change detection config (#2212)
We generally care about preserving JSON compatibility for protobuf
files, but for some files, where we only use pure gRPC, we only
care about preserving wire compatibility.

Split our buf breaking invocation into two invocations, one that checks
for WIRE_JSON compatibility, and one that checks only for WIRE
compatibility. The former check ignores protos in controller/servers,
since they do not need to adhere to this stricter definition.
2022-06-17 11:58:37 -04:00
Johan Brandhorst-Satzkorn d06ac0d370 Propagate plugin execution dir to CreatePlugin (#2183)
* fix: Propagate plugin options to CreatePlugin

Plugin options were previously only applied to the
BuildPluginMap call, resulting in the plugin
execution_dir variable being ineffective.

Also add a test to verify functionality

* fix: Support plugin execution_dir for all plugins

Previously, only external host plugins would respect
the plugin execution dir. Now, all uses of the embedded
plugins respect the configuration.
2022-06-15 16:16:18 -04:00
Johan Brandhorst-Satzkorn a2477420da chore: Clarify event file sink doc (#2162)
Updated examples to show the common use case of
specifying a directory path and file name for
a file sink. This should hopefully prevent users
from making the mistake of putting a full path
for the file_name field and seeing an error like:

[ERROR] unable to send event: operation="event.(Eventer).retrySend"
  warning=
  | 1 error occurred:
  | 	* mkdir : no such file or directory
  |
2022-06-10 13:30:05 -04:00
Johan Brandhorst-Satzkorn 8fdc07d5a5 test: Use tparse to simplify test failure analysis (#2149)
The tparse library adds a nice summary of the test output,
which should hopefully make it easier to find errors in the tests
2022-06-09 13:02:55 -04: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
Johan Brandhorst-Satzkorn b20939ecb4 fix(cmd): Fix build error (#2107)
This seems to have been missed when #2094 was
reviewed and merged.

Blame: ec608b79da
2022-05-25 15:40:36 -04:00
Johan Brandhorst-Satzkorn ec608b79da fix(cmd): Respect DB max open connections (#2094)
Both the init and migrate commands were ignoring
the configured max_open_connections database
setting. This fix ensures that both commands
respect the limits.
2022-05-23 08:21:15 -04:00
Johan Brandhorst-Satzkorn 8cef1017e9 fix(session): Fix typo in connection documentation (#2075) 2022-05-12 16:11:35 -04:00
Johan Brandhorst-Satzkorn 8ed560fc3e Add memory profile build target (#1960)
* fix(cmd): Add profiling build imports

It seems like this file has been bitrotted since last used,
and it was missing some imports. This was discovered
by running goimports on the code.

* Add build-memprof Makefile target
2022-05-09 10:16:10 -04:00
Johan Brandhorst-Satzkorn 780d913596 chore: Add .git-blame-ignore-revs (#2059)
This lets us ignore large changes in blame. Use it
to ignore the Protobuf file formatter commit.

See https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view
for more information.
2022-05-04 12:14:07 -04:00
Johan Brandhorst-Satzkorn f69fbf2255 feat(proto): Format protobuf files with buf (#2033)
Formats all protobuf files with buf format. This ensures
a consistent style across all our protobuf files, similar
to gofumpt.
2022-05-04 11:10:21 -04:00
Johan Brandhorst-Satzkorn 95c5063500 chore: Prepare for next release 2022-05-03 17:27:14 -04:00
Johan Brandhorst-Satzkorn f39553abb3 chore: Release prep for v0.8.0 2022-05-03 10:33:36 -04:00
Johan Brandhorst-Satzkorn 21b0d584ad feat(dbtest): Add benchmark dump generator
Generate dumps ahead of time so that they can
be used for benchmarks without prohibitive
startup costs.

Fixes https://hashicorp.atlassian.net/browse/ICU-4039
2022-04-29 16:33:44 -04:00
Johan Brandhorst-Satzkorn e864652b33 feat(sessions): Add list benchmarks
The list benchmark tests uses pre-created database
dumps to run its benchmarks. This benchmark
will be used to guide optimizations around listing
of sessions.

Fixes https://hashicorp.atlassian.net/browse/ICU-4042
2022-04-29 16:33:44 -04:00
Johan Brandhorst-Satzkorn 5d042c7ec7 feat(dbtest): Mount DB dumps and create templates
Mount the benchmark dump directory when running
the test database and create a new script for creating
templates from the dumps. This makes it easy to create
pre-populated databases for benchmark tests.

Fixes https://hashicorp.atlassian.net/browse/ICU-4040
2022-04-29 16:33:44 -04:00
Johan Brandhorst-Satzkorn 9e424db0a3 test(session): Ignore unique error on session create
Sometimes when creating a lot of sessions concurrently we
can run into a unique constraint error in the warehouse triggers
in the database. Simply retrying the call will allow the
session creation to succeed.
2022-04-29 16:33:44 -04:00
Johan Brandhorst-Satzkorn 7f9b294a7e refact(all): Use testing.TB for test helpers
Our test helper packages were not possible to use
with benchmarks. This refactor switches to testing.TB
to allow both tests and benchmarks to use the helpers.
2022-04-29 16:33:44 -04:00
Johan Brandhorst-Satzkorn a7a2c82931 feat(dbtest): Add docker-load Makefile target
The new docker-load target uses docker buildx to build
a local image of each of the Dockerfiles, and load them
into the local docker socket image store.
2022-04-29 16:33:43 -04:00
Johan Brandhorst-Satzkorn 89196f2ce7 Remove old migration code & Avoid db test image confusion (#2038)
* refact(dbtest): Remove old migration code

This is no longer needed, so we can clean up this
script a bit.

* refact(dbtest): Change test image env var

The existing environment variable clashes with
the one used in the top level Makefile. The new
name prevents confusing behavior when setting
the env var and creating the test database from
the root of the repository.
2022-04-25 17:39:23 -04:00
Johan Brandhorst-Satzkorn a1c656ca94 fix(event): Remove wrapper validation (#2032)
The wrapper is sometimes unset at the time when the
audit config is validated, so it is impossible for us
to validate that a valid wrapper is configured. The wrapper
is configured by later setup steps because of a dependency
on the eventer in our KMS setup.
2022-04-20 17:42:39 -04:00
Johan Brandhorst-Satzkorn 243a4c4616 Merge llb-audit-events into main
Classify fields for all api and cluster protobuf messages.
Before classification, audit events would be completely redacted.
Now events will contain unredacted values according to classification.
Audit events are now no longer considered a WIP.
2022-04-20 14:02:34 -04:00
Johan Brandhorst-Satzkorn 8c452b0991 feat(authmethods): Add classification to all fields 2022-04-20 13:32:32 -04:00
Johan Brandhorst-Satzkorn fc6cddfc7f feat(authtokens): Add classification to all fields (#1996) 2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn d51ce41db8 feat(hostsets): Classify all proto fields 2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn 8fa3e8dee0 feat(hostcatalogs): Classify all proto fields 2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn 5440195cce feat(hosts): Classify host proto fields 2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn a2bff4efdf feat(authmethods): Add typed attributes to authenticate request and response
The AuthenticateRequest and AuthenticateResponse types have a
complex mapping rule system, which requires a pair of custom
callback functions.
2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn 0e51f9cc92 feat(authtoken): Add token type to AuthToken
The token type is used in the response from the OIDC
Authenticate method only.
2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn 5b71aa6212 refact(subtype): Remove copied structToProto methods
The original idea was for these methods to eventually become
entirely encapsulated by the subtype package, but as it turns
out we still have use for them in custom transformation functions,
so move the subtype package to use these shared functions
instead.
2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn 6d56fcd26f feat(subtypes): Add new transformation registration option
This allows the user to register a custom transformation callback
for a specific protobuf message, in cases where the transformation
is sufficiently complex for it to be cumbersome to formalise
the logic through protobuf options.
2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn 1fd44ee0f1 refact(subtypes): Remove return from transformations
This return value is just a reference to the input, which
is being mutated. We may as well make that clear via
the signature, which will also simplify the new custom
transformation function registration logic.
2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn 53481146fd feat(authmethods): add well typed attribute options (#1972)
Add well typed attribute options to the authmethods proto
definitions, while hiding them from being rendered in
the openapiv2 spec.
2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn ec25e7682c fix(controller): Clone messages before auditing (#1982)
It is not unreasonable for downstream users of the request and response
messages to mutate them, indeed we mutate the response
on the way out to get the desired external API. To avoid
inconsistent messages being audited, make a copy of the
entire message before returning from the interceptor.

This was discovered while testing the new subtype transformation
interceptor.
2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn 6e6efeee71 feat(account): Add gotags classification
Add gotag classification to all account proto and service definitions.
2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn ac5a1acca8 feat(account): Hide internal attribute fields
These fields are not intended for use by API consumers, so we hide
them from the generated API documentation by marking them as INTERNAL.
2022-04-20 13:32:31 -04:00
Johan Brandhorst-Satzkorn 6a37bd9710 Upgrade grpc-gateway version to v2.10.0 (#1954)
This new version will let us hide fields from the OpenAPI output
2022-04-20 13:32:29 -04:00
Johan Brandhorst-Satzkorn 80b2c9230f refact(authmethods): Add top level token type to Authenticate (#2010)
Other parts of the system make use of a "type" field, while the
AuthenticateResponse sets a "token_type" on the response attributes
directly. Rename this field to "type", and move it up to the response
level, to be more consistent with other RPCs.

Also adds a new field to the AuthenticateRequest, "type" which will
replace the "token_type" field over time.
2022-04-18 09:26:15 -04:00
Johan Brandhorst-Satzkorn 8d80d10ff7 fix(controller): Cancel tests on fatal errors (#1994)
When requesting a token, any error is fatal to the test.
The previous behavior would return a nil token, which
could cause subsequent uses to panic. This will instead
interrupt any test immediately on error.
2022-04-12 16:56:04 -04:00
Johan Brandhorst-Satzkorn f2fa1142d3 fix(test): Remove uses of t.FailNow in goroutines (#1978)
It is documented as illegal to use t.FailNow in a goroutine.
Uses of require assertions call t.FailNow. This may have led to
inconsistent test results as some assertions were subject to
undefined behavior. Note that it is still allowed to call
assert assertions in goroutines.

See: https://pkg.go.dev/testing#T.FailNow
2022-04-07 09:26:34 -04:00
Johan Brandhorst-Satzkorn b1d6a1da9a Switch to buf for protobuf generation (#1944)
* Install buf with go install

This reduces the impact of using buf on our dependency
closure, which was significant. It also avoids potential
issues with building buf given our own internal dependency
constraints. This has caused issues (including crashes!)
in the past.

See https://github.com/cockroachdb/cockroach/issues/67216#issuecomment-874176186
for more discussion on using tool dependencies generally, and
https://github.com/bufbuild/buf/issues/52
for an example of where this sort of thing caused an issue for a user.

* Upgrade buf version

We should migrate to v1 sooner rather than later, as it has some
breaking changes from v0.

* Change buf lint/breaking commands

These commands were moved up one level for v1

* Migrate to buf.yaml to v1

* Remove unused imports

These were uncovered by using "buf lint".

* Use buf v1.3.1

* Depend on googleapis and grpc-gateway via BSR

* Switch to buf for proto generation

* Remove third party dependency

* Remove unused tools and scripts

* Move local protos up one level

* Temporarily don't fail on breaking changes

* Generate CI config

* Fix generation of controller.json

* Replace use of deprecated flag

* Remove unused import, regenerate files

* Remove temporary skipping over breaking check
2022-04-04 13:55:42 -04:00
Johan Brandhorst-Satzkorn 121a296a7f Refactor file formatting target (#1951)
Use the standard Go heuristic for determining
whether a file should be ignored by formatting
for being a generated file.

This is effectively a no-op change today, but
if we add new generated files in the future,
we should automatically ignore them in formatting.

This is a slightly updated version of #1941 that should
work across all versions of grep.
2022-03-29 15:37:25 -04:00
Johan Brandhorst-Satzkorn 63d3481031 Revert "Refactor file formatting target (#1941)" (#1949)
This reverts commit 9029720664. It
was causing unexpected errors on some platforms. More investigation
will be necessary.
2022-03-25 17:54:02 -04:00
Johan Brandhorst-Satzkorn 9029720664 Refactor file formatting target (#1941)
Use the standard Go heuristic for determining
whether a file should be ignored by formatting
for being a generated file.

This is effectively a no-op change today, but
if we add new generated files in the future,
we should automatically ignore them in formatting.
2022-03-25 13:20:10 -04:00
Johan Brandhorst-Satzkorn 803d916279 Update zalando/go-keyring with freebsd fix (#1938) 2022-03-22 09:52:42 -04:00
Johan Brandhorst-Satzkorn 9dc8c45634 Revert version upgrade of dbus and go-keyring (#1936)
* Revert version upgrade of dbus and go-keyring

The combination of these versions were causing build errors on freebsd

* Only revert zalando/go-keyring
2022-03-18 16:32:43 -04:00
Johan Brandhorst-Satzkorn 89273a2f3e Update references to "make dev" (#1920)
"make dev" has been replaced with "make install" since b53e4d4c3e.
2022-03-16 16:39:53 -04:00