Commit Graph
860 Commits
Author SHA1 Message Date
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
Timothy Messier 02b2291375 feat(subtypes): Make Registry thread-safe 2021-10-19 10:44:51 -04:00
Timothy Messier eac433f7ff refact(target): Move tcp into subpackage
This moves all of the tcp target functionality into a tcp package. It
also establishes a Register function in the target package to allow
specific target types to be registered at initilazation time. When
registering, a target type needs to provide its Subtype, as well as some
RepositoryHooks that are used by the target Repository.
2021-10-19 10:44:51 -04:00
Timothy Messier 51812ff779 docs(target): Mark additional fields as output only (#1609)
When creating or updating a target, the following fields should have
been marked as output only:

- host_set_ids
- host_source_ids
- application_credential_source_ids
- application_credential_library_ids

This updates the protobuf and generated files including the swagger file
used by the docs site to correctly mark these are output only.

Fixes #1588
2021-10-19 09:37:32 -04:00
Jeff Mitchell c05324282f Rename the UI passthrough dir flag/env var (#1600)
This puts it more in line with other upcoming options that use "dir"
instead of "directory" (plus it's easier to type), and makes it clear
that this directory and the passthrough behavior is related to the UI as
opposed to other upcoming items.
2021-10-14 12:13:07 -04:00
Jim 3b99ded7ad refactor: Update gorm deps (#1591)
Our recent upstream PR was merged into gorm.  We needed to change
just a few bits to migrate our gorm dep back to the upstream source.
2021-10-13 11:10:11 -04:00
Michael Gaffney 7ccab48a3c style: Run make fmt 2021-10-11 16:00:32 -04:00
Timothy Messier e3f7c263b0 refactor(sqltest): Update init script to support migration editions
This updates the docker image used for tests to support the new location
for sql migration files and the concept of editions. It continues to
process the old paths for now if the new directory does not exist, so
that the same image can be used during the transition.
2021-10-08 06:50:26 -04:00
Timothy Messier 8caaf3e076 refactor(schema): Add support for migration editions
This refactors the schema package and subpackages to support editions.
An Edition is a collection of sql migrations. A given boundary binary
can have multiple migration editions. The `schema.Manager` is updated to
apply the necessary migrations in the correct order, leveraging an
Edition's priority to determine the order in which the separate Editions
are applied.

The sql migration files are now nested under a directory for the
edition.

This also switches from the generated code to using embed, which
eliminates the need for the `make migrations` target and the generated
code. As such this commit removes the target and generated code.

See:
    https://pkg.go.dev/embed
2021-10-08 06:50:26 -04:00
Jeff Mitchell 217adfc4d2 Pull over CombinedSliceFlagValue from WIP plugin-hostcatalogs (#1582)
I've pulled over files as-is for the most part so this also pulls over
some common attribute/secret flags but it's not worth dealing with the
merge later...
2021-10-07 15:30:39 -04:00
Jim c8b29ded1c Events: Add outbound detail protobufs, request status code, and update event encrypt filter. (#1569)
* feat (events): Add status code to audit events

* feat (events): Add the resp proto msg to every audit event

* chore (events): Update eventlogger dep

This latest version will redact any map and/or map field which isn't
explicitly classified via a Taggable interface

* feat (events): Begin to add tagging to response proto msgs
2021-09-30 12:55:47 -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
Jim 350b79be2d chore: Update go:build tags to new fmt 2021-09-27 16:24:00 -04:00
Randall Morey 0eb1ab1698 chore: bump UI commit (#1565) 2021-09-27 14:28:36 -04:00
Timothy Messier 88b3c8358c feat(cmd): Include version metadata in output (#1560)
If the VersionMetadata is set, include it in the output of the `boundary
version` subcommand.
2021-09-23 12:22:20 -04:00
Louis Ruch 49d5711a49 fix (service): corrects permission bug in hostset service (#1549)
* fix (service): corrects permission bug in hostset service

* fixup! fix (service): corrects permission bug in hostset service
2021-09-22 11:01:51 -07:00
Todd 0ba217cbfa Run make tools and make gen now that the dependencies have been updated. (#1552) 2021-09-21 10:32:26 -04:00
Louis Ruch 1c40100edd tests(scheduler): fix unit test deadlock (#1550)
If a new job is started as the test successfully compeltes and begins
the scheduler shutdown process.  The new job will deadlock waiting on
channel reads.
2021-09-20 11:31:54 -07:00
Jim 5312f7d042 fix (credential/vault): Correct typo in error msg (#1547)
* fix (credential/vault): Correct typo in error msg

* test (vault): Add missing assertion
2021-09-20 11:42:04 -04:00
Louis Ruch 6000f20ae5 chore(authenticate): remove deprecated authenticate:login and credentials field (#1534)
* chore(authenticate): remove deprecated authenticate:login

* Update changelog
2021-09-17 18:23:24 -07:00
Jeff Mitchell 7fc712de44 Bump protoc 2021-09-17 16:23:25 -04:00
Louis Ruch 6a92e08928 refact(worker): update worker porxy handler signature to return an error (#1536)
Instead of requiring the each proxy handler to handle the webSocket
connection closure.  On error the worker handler will appropriately
close the connection and event any errors.
2021-09-17 11:48:44 -07:00
Louis Ruch 8b5e4a175a feat(worker): add egress credentials option to proxy (#1531) 2021-09-17 11:26:04 -07:00
Jeff Mitchell bc240da52b Fix word ordering 2021-09-17 13:48:26 -04:00
Timothy Messier 99d0d2f682 wh: Add wh_credential_dimension and bridge tables
This adds new dimension table to record credential information. Since a
session can have multiple credentials, the wh_session_accumulating_fact
is is linked to the credential_dimensions via bridge tables,
wh_credential_group and wh_credential_group_membership. When a session
is inserted, the credental group and credential dimensions will be
upserted. If the group changed in any way, a new group is inserted along
with all of the corresponding credentials.
2021-09-16 08:53:11 -04:00
Jeff Mitchell 1f7999ed97 Add authorized collection actions output for credential stores (#1530)
Add authorized collection actions output for credential stores
2021-09-15 13:51:15 -04:00
Michael Gaffney e9d3cebd45 feat(credential): Add specific credential types (#1525)
This adds interfaces for the following credential types:
- Username and password
- Username and private key
- Certificate and private key

It also adds the following types for redacting secret data:
- Password
- PrivateKey
2021-09-14 14:11:42 -04:00
Jim 2afac7348a fix (controller): Set controller CancelCtx (#1513) 2021-09-14 05:49:18 -04:00
Jeff Mitchell 70cb75d030 Fix sessions authorized actions output (#1527) 2021-09-13 20:26:42 -04:00
Jeff Mitchell 92809b733a Fix unknown permission issue with credential-store (#1524)
This also affected credential libraries and managed groups. It seems
that any end-to-end tests of these grants currently had them included in
wildcards instead of individually, but these types were never added to
the valid list for resources. Additionally, credential store wasn't
added as a valid top level type for pinning purposes.
2021-09-13 13:56:44 -04:00
Timothy Messier 2ee1d4e6e4 refactor: Make docker pacakge an internal package of cmd/base
The docker package and its StartDbInDocker function should only be used
by the `boundary dev` command now. So moving it into an internal package
of `base` will prevent it from being use for tests accidentally, while
still allowing it to be used for `boundary dev`.
2021-09-09 13:42:01 -04:00
Timothy Messier 75388f727a test: Refactor to use dbtest package instead of docker
This swaps the test initialization to use the dbtest package so each
test will get a fresh database created from a template database, instead
of a completely new docker container.
2021-09-09 13:42:01 -04:00
Randall MoreyandSusmitha Girumala 7746916d59 chore: bump UI version for release (#1514)
Co-authored-by: Susmitha Girumala <susmitha@hashicorp.com>
2021-09-08 16:08:36 -04:00
Jeff Mitchell e9a8ede0d6 Move wrapper package back to SDK (#1511)
TF uses this, so SDK is a decent place for it. It doesn't create
dependencies between it and API.
2021-09-08 12:15:42 -04:00
Jeff Mitchell 081de3cf79 Migrate sdk/recovery to api/ and sdk/wrapper to internal (#1507)
* `recovery` is only used by the API (and the main module, for decryption)
* `wrapper` is only used by the CLI right now

Moving these brings them closer to the code that uses them, and makes
the SDK package a bit more clear in terms of functionality.
2021-09-07 22:13:19 -04:00
Randall Morey 700ed0b138 chore: bump ui (#1508) 2021-09-07 15:16:03 -04:00
Louis Ruch 61722659d1 test(scheduler) Remove un-needed test causing intermittent failures (#1501) 2021-09-04 07:30:31 -07:00
Randall Morey ffc01b141d chore: bump UI version and add UI changelog (#1503) 2021-09-03 15:45:15 -04:00
Jim 5fe40bc7bd style (events): add changes from make fmt in prep for release. 2021-09-03 14:35:42 -04:00
Louis Ruch 4cdce29a84 fix(connect): Remove erroneous event error message (#1500)
When a session is terminated by the user, the cancel session path is
triggered, in this path the websocket connection is closed.  If the
connection is already closed, an EOF is returned. In this situation an
EOF is expected and should not be logged to the user.

Example log line:
{
  "id": "ezqk6w9dOQ",
  "source": "https://hashicorp.com/boundary/dev-controller/boundary-dev",
  "specversion": "1.0",
  "type": "error",
  "data": {
    "error": "failed to close WebSocket: failed to read frame header: EOF",
    "error_fields": {},
    "id": "e_n60YPsDkaj",
    "version": "v0.1",
    "op": "worker.(Worker).handleProxy",
    "info": {
      "msg": "error closing client connection"
    }
  },
  "datacontentype": "text/plain",
  "time": "2021-09-02T10:05:46.587513-07:00"
}
2021-09-02 12:24:12 -07:00
Jeff Mitchell 2c61bd4963 Fix recursive listing when the ingress scope lacks permissions (#1478)
The existing logic was to ignore Forbidden errors when recursively
listing in favor of looking for downstream scopes with appropriate
permissions. The problem is that when there is actually no
authentication token at all, what comes back is an Unauthenticated
error. Therefore if you didn't have permissions on the ingress scope
(e.g. the default of `global`) but did downstream for the anonymous
user, you'd get back an error.

I don't think there's any security issue with doing this; the user could
always have simply started the search at a downstream scope to begin
with so nothing more is being revealed, this just fixes behavior to
match expectations in this case.

A test was added for one of the services; the code is exactly the same
across them. The reason that the existing tests that were added with the
output fields testing didn't catch this is that even though they were
specifying `u_anon` as the user, the disabled test context skipped the
logic that would return a 401 in this case. It turns out that fixing
this is very complicated because we don't have a great way in most tests
of defining grants to put onto the generated scopes, so even if a true
anonymous context was added each test would require the anonymous user
to have list permissions on whatever resource was under test, requiring
a lot of role and grant and principal finagling. This is probably a good
longer-term TODO but not one that seemed worth it for this fix.

Fixes ICU-2301
2021-09-02 12:55:04 -04:00
Jeff Mitchell 781871c30d Properly accept grant format type=<type>;output_fields=<of> (#1474)
Although we document that this is allowed, and the ACL code handles it,
some of the validation code did not. This would cause a semi
intermittent problem because that validation code is used only in some
code paths; specifically we skip it (for now) to avoid erroring out on
some deprecated grant string formats when reading grants from the DB,
but we use it to error out when validating incoming grants.
2021-09-02 12:54:02 -04:00
Louis Ruch 030c09c6b9 bug(targets): Fix panic in authorize-session (#1496)
When renaming credential libraries -> credential sources
the target service added the credential library information
to the SessionCredential response, while the target cmd was
parsing the credential source.

This prevents a panic like the following:

    boundary targets authorize-session -id ttcp_5PS2dktESb
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x1f99a31]

    goroutine 1 [running]:
    github.com/hashicorp/boundary/internal/cmd/commands/targetscmd.printCustomActionOutputImpl(0xc00046c0a0)
    	/Users/louisruch/boundary/internal/cmd/commands/targetscmd/funcs.go:822 +0x9d1
    github.com/hashicorp/boundary/internal/cmd/commands/targetscmd.(*Command).Run(0xc00046c0a0, {0xc000134030, 0x2, 0x2})
    	/Users/louisruch/boundary/internal/cmd/commands/targetscmd/targets.gen.go:324 +0x188b
    github.com/mitchellh/cli.(*CLI).Run(0xc0001c6500)
    	/Users/louisruch/go/pkg/mod/github.com/mitchellh/cli@v1.1.2/cli.go:262 +0x5f8
    github.com/hashicorp/boundary/internal/cmd.RunCustom({0xc000134010, 0x60, 0x0}, 0x0)
    	/Users/louisruch/boundary/internal/cmd/main.go:186 +0x9d6
    github.com/hashicorp/boundary/internal/cmd.Run(...)
    	/Users/louisruch/boundary/internal/cmd/main.go:92
    main.main()
    	/Users/louisruch/boundary/cmd/boundary/main.go:13 +0xc9

Fixes #1488
2021-09-01 09:16:47 -07:00
Louis Ruch db8e9bb0c6 refactor(worker): refactors the proxy handler to use endpoint scheme (#1491) 2021-09-01 07:22:45 -07:00
Jim 5f46207e76 Events: add redact/encrypt node for audit events to Eventer (#1490)
* feat (events): Add new options needed for AuditConfig

WithAuditWrapper and WithFilterOperations all for optional paramters
when creating AuditConfig types.

* refactor (event): Change EventerConfig.Sinks to a ptr

We need to modify the SinkConfig.AuditConfig during the NewEventer factory, so we have to use a ptr not a ref.

* feat (events): Add audit configuration types

* feat (events): add audit config to sink configuration.

* feat (events): add redact/encrypt node for audit events to Eventer

Integrate the encrypt.Filter node from the eventlogger into the
event.Eventer, so audit events can be redacted/encrypted based
on data classifications.

* test (events) Add test protobufs for events

Add test protobufs along with a test service for testing
the audit event encrypt node
2021-08-30 19:02:48 -04:00
Timothy Messier 90e2c871f0 refactor(wh): Remove host prefix from wh_user_dimension org fields
These fields are being refactored so they conform with the new
wh_credential_dimension. This will inform Business Intelligence tools
that these attributes conform across dimensions.
2021-08-30 14:25:30 -04:00
Timothy Messier 026f09a9a8 refactor(wh): Rename primary and foreign key columns
The tables in the operational part of the Boundary database (meaning
non-warehouse tables) suffix primary key columns and foreign key columns
with `_id`. Many of these columns appear in the warehouse dimension and
fact tables as normal attributes, not primary keys or foreign keys. To
disambiguate ID columns from operational tables, the primary key column
for dimension tables will be renamed from `id` to `key` and the foreign
key columns in the fact tables will be renamed to change the suffix from
`_id` to `_key`.
2021-08-30 14:25:30 -04:00
Timothy Messier c8bf1917f5 db: Refactor test setup for pre-populated data
Now when initializing the test database for sql tests,
it will load the colors persona data into the database. This will
provide a data set that tests can use without needing to call
`wtt_load`.

The main motivation is to allow for a separation of setup and test
execution that requires crossing a transaction boundary. The pgTap tests
are required to exectue as a single transaction, so that the rollback
can reset the state, and each test can be isolated. However, can cause
issues with some test senarios, particuarly with the use of some times
releated functions like `current_timestamp` and `now` which return the
time that the current transaction started. This creates an issue if a
test relies on some setup that sets a time via `now`, then an update
that expects a new time via `now`.

See: https://www.postgresql.org/docs/13/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT
2021-08-30 14:25:30 -04: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