Commit Graph
166 Commits
Author SHA1 Message Date
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
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
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
Damian Debkowski c2bfcc0664 refactor(api module): enforce typed definitions (#2238) 2022-07-21 15:21:31 -07:00
Todd 19b549c44a Rename package servers to server (#2222) 2022-06-20 18:20:17 -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
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
Jeff Mitchell 4cf2a87e8d Update targets to new listing method (#2045)
This uses the prefetch method to fetch resource IDs and validate them
for authz by the user before then fetching the full list of targets.
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 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
Timothy Messier 185d8b392d refact(auth): Move subtype registration into global registry 2022-04-20 13:32:31 -04:00
Jim addbfee593 chore: upgrade gofumpt to v0.3.1 (#2028) 2022-04-19 11:42:54 -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
Jeff Mitchell 7eb29261b2 Update to go-kms-wrapping version 2, and plugin-based KMS (#1901) 2022-03-16 17:04:07 -04:00
Jim 591ec476e7 refactor: Update internal/db and oplog to use go-dbw package for database operations. (#1785)
* chore: Add new dbw dependency

* refactor: Convert to use dbw.DB

* refactor (db): Change GetTicket(...) signature

* feature (db tests): Added TestDeleteWhere(...)
Adding this allows us to eliminate a leak of the gorm library

* refactor: Add ctx to ScanRows(...) signature
This is required to refactor all the deprecated errors pkg calls.
This refactor required adding a context to quite a few call chains
and in particular the job scheduler bits

* feature (db/tests): Add support for test opt: WithTestLogLevel(...)
This test only option allows callers to specify a log level for the
underlying db package (where supported/applicable) when calling
TestSetup(...)

* refactor (db): Simplify Db type
Only store the underlying *DB and create the *RW on demand when
needed.

* refactor (oplog): Port to using dbw pkg for db operations

* refactor (db): Remove gormDB(...) func

* tests (db): Add unit tests for TestDeleteWhere(...)

* chore: make fmt changes to formatting
2022-01-05 14:38:38 -05:00
Jim 5232be905b fix (auth/oidc): Revert to working version of oidc acct upsert (#1719) 2021-11-16 19:32:50 -05:00
Jeff Mitchell 80d41b9044 Merge branch 'main' into plugin-hostcatalogs 2021-11-04 09:02:39 -04:00
Jim dd2c3807cd refactor: Move functions from kms pkg to new libs/crypto pkg (#1650) 2021-11-04 08:55:30 -04:00
Jeff Mitchell 0fd906d964 Merge branch 'main' into plugin-hostcatalogs 2021-10-21 11:47:13 -04:00
Jim 1ce9a71b53 feature (db): Add on conflict support to db.Create(...) (#1612) 2021-10-21 11:11:56 -04:00
Oleg Butuzov 5a2fa689a7 refactor: replace (*regexp.Regexp).Match on (*regexp.Regexp).MatchString (#1617)
This PR change one method of regexp.Regexp struct with a similar one,
as result code produce less allocations on heap.
2021-10-21 08:02:15 -04:00
Jim 769416c2ff refactor (controller): Use a grpc server for the grpc-gateway (#1576)
* refactor (controller): Use a grpc server for the grpc-gateway

This starts a grpc server for the grpc-gateway.  The new gateway
server uses an in-memory listener which also supports "dialing", so
the http proxy can connect to the in-memory listener.

This change allows us to use all grpc server features and was in part
motivated by a need for an interceptor of inbound requests.  With that
said, having a "proper" grpc server for the gateway will provide a lot
more flexibility and capabilities moving forward.

The request context will still be verified via middleware in the
http proxy (see wrapHandlerWithCommonFuncs).  This verified context
will be serialized into a protobuf and sent along to the grpc-gateway
via metadata where an interceptor will add the verified request
info to the request's context (see requestCtxInterceptor).  The
interceptor will verify the serialized request info via a shared ticket
with it's companion in-memory http proxy.  FYI: the ticket is simply
random base62 string (see db.NewPrivateId).

This change also necessitated a minor change to services.  We need to
return an empty response instead of nil, nil when there are no errors
and the response is empty.

* refactor (handlers): Rename gRPC Gateway filter

Originally, this was called an OutgoingInterceptor, which is an
unfortunate name since it's not an interceptor.  Now that we're
refactoring the gateway stuff and have proper interceptors, renaming
this should remove ambiguity

* refactor: Rework how 204 with empty msg is handled

Recent changes to grpc gateway has necessitated a change to how
204s are handled by the gateway

* tests (bats): Check status codes for delete operations
2021-10-19 17:21:41 -04:00
Jeff Mitchell f6efde041d Merge branch 'main' into plugin-hostcatalogs 2021-10-14 10:09:58 -04:00
Michael Gaffney 7ccab48a3c style: Run make fmt 2021-10-11 16:00:32 -04:00
Jeff Mitchell 158ab09952 Merge branch 'main' into plugin-hostcatalogs 2021-10-05 16:27:28 -04:00
Jim 8d6dee09a9 refact: Add db.DB wrapper and refact all test fixtures to use it. (#1535)
* refact: Changes required for gorm v2

* refact: Add db.DB wrapper and refact all test fixtures to use it

Stop leaking the gorm abstraction within our unit tests.

* refact: Migrate direct calls to pq to pgx driver

The refactor will remove the remaining direct dependencies on
the pq driver which has been deprecated in favor of the pgx
driver.

It includes the addition of common.SqlOpen which is a wrapper around
sql.Open, which is needed to deal with the driver name changing from
"postgres" to "pgx" but in our code base the dialect and driver are
synonyms.
2021-09-30 09:17:27 -04:00
Jim 136ac00b49 refact: Changes required for gorm v2 (#1528) 2021-09-30 08:47:34 -04:00
Jeff Mitchell f9c620a5d5 Merge branch 'main' into plugin-hostcatalogs 2021-09-17 16:26:44 -04:00
Jeff Mitchell 7fc712de44 Bump protoc 2021-09-17 16:23:25 -04:00
Todd Knight 1249f9668f Add Plugin Host Set Repo Create, List, Read Operations (#1497)
Add repo for plugin based host sets as well as tests.
2021-09-09 10:45:41 -07:00
Jeff Mitchell 2649d1b966 Move protooptions to sdk/pbs (#1486)
This prevents a reverse dependency from sdk on the main module.
2021-08-26 11:04:32 -04:00
Jeff Mitchell f7894811f5 Update go-bexpr to allow colons in paths; add a test (#1453) 2021-08-11 15:27:56 -04:00
Todd Knight 39cc245966 Make gen after make tools. Includes make fmt of existing non generated files. (#1438) 2021-08-02 10:46:09 -07:00
Jim 68dd2a66ba Remove unneeded hclog dependencies as we move forward with events (#1433) 2021-08-01 14:41:13 -04:00
s-christoffandJim 6b78108ecf Update primary error functions to take a context, deprecate old functions (#1358)
* add new error funcs which take a ctx and deprecate existing funcs

* use context where available when writing error events

* remove circular internal/errors pkg dep

* suppress some chatty errors using errors.WithoutEvent()

* convert auth oidc funcs to take context where needed to write events

Co-authored-by: Jim <jlambert@hashicorp.com>
2021-07-29 20:52:56 -04:00
Todd Knight 10e8aeae4b Subtype Id registration moved to its own package (#1416)
* Allow repo packages to register subtypes and id prefixes. 
* Refactor out request authentication logic to a new package as a sibling to handler.
2021-07-27 09:59:52 -07:00
Jeff Mitchell 528d54b4ad Add token/userinfo claims to account read output (#1419)
This is very useful when trying to write managed groups filters as you
can directly look at the structure of the claims for the accounts you're
trying to filter.

The output of the claims in text format on the CLI currently leaves
something to be desired. I started revamping some of the formatting
functions and it quickly got very fragile. Fundamentally at this point
we're likely better off -- now that we have a good idea what our output
format/standards are like -- rewriting the formatting code. I'll take
that as a tasker as I have a lot of ideas...
2021-07-26 17:52:18 -04:00
Jeff Mitchell ed6c59a053 Update the rest of the shared libs locations 2021-07-14 17:50:15 -07:00
Jeff Mitchell ce52acb968 Update strutil import 2021-07-14 17:37:40 -07:00
Jeff Mitchell 2cbcf9a563 Update usage of shared-secure-libs (#1393) 2021-07-12 21:06:22 -04:00
Louis Ruch 466219f109 Add gostringer to client_secret (#1315) 2021-06-16 11:44:08 -07:00
Jeff Mitchell 054c0aa538 Update password generated account IDs (#1290) 2021-06-08 12:31:58 -04:00
Jeff Mitchell 4d27b58d2d Add managed groups test (#1289) 2021-06-07 20:35:45 -04:00
Jeff Mitchell b513f21153 Add test for GrantsForUser (#1287)
* Start of test

* Add a test for existing GrantsForUser functionality.

The test has randomization built in to allocate users across groups and
both users and groups across roles. It tracks which users and groups
have been assigned to which roles, then ensures that GrantsForUser
returns the correct set of roles for a given user.

This required modifying the CTE in GrantsForUser to return role_id as
well.

This doesn't test managed groups yet, that will come in a follow-on PR.
2021-06-07 10:19:21 -04:00
Jeff Mitchell 9ecc384007 Add managed group support to role principals (#1270) 2021-06-04 10:44:57 -04:00
Jeff Mitchell ad93315b59 Add predictable account IDs in dev mode (#1271) 2021-06-04 10:35:51 -04:00
Jeff Mitchell 5c8a8c3998 Merge remote-tracking branch 'origin/main' into ICU-1573 2021-06-03 13:39:44 -04:00
Michael Gaffney 094bdcdd2b protobuf: remove unused imports (#1267)
This removes unused imports in the protobuf files which are reported as
warnings by the protoc compiler.
2021-06-02 14:59:36 -04:00
Jeff Mitchell 9208d10936 Merge branch 'main' into ICU-1573 2021-06-02 14:09:02 -04:00