Commit Graph
1197 Commits
Author SHA1 Message Date
Jim 785241237e refactor (kms): adopt the go-kms-wrapping/extras/kms package (#2027)
* feature (db): add Db.UnderlyingDB()

This is needed to allow for integration with bits that need a *dbw.DB

* feature (kms): add new go-kms-wrapping/extras/kms dependency

* refactor (kms): schema changes required to adopt extras/kms pkg

* refactor (kms/iam): rename to DeprecateCreateKeysTx(...)

* refactor (kms): remove deprecated test

* refactor (kms): refactor Kms type

This refactor includes renaming the existing type to DeprecatedKms
and then refactoring the Kms type to become a wrapper of
go-kms-wrapping/extras/kms

* refactor (kms): delete all the unneeded bits

All this stuff is not needed now that we're using
go-kms-wrapping/extras/kms

* refactor (db): fixup tests after kms refactor

* refactor (kms/tests): 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.

* tests (session benchmarks): refactor to use new Kms type

* refactor (schema): rm test which relies on deprecated Kms code

* refactor (kms): post rebase on main changes required

* chore (kms refactor): re-add unit test from main

* refactor (kms): uses migrations that don't include KMS schema changes
2022-05-13 13:53:22 -04:00
Johan Brandhorst-Satzkorn 8cef1017e9 fix(session): Fix typo in connection documentation (#2075) 2022-05-12 16:11:35 -04:00
irenarindos 54c30d2cad bug(session): null fkey trigger also checks for session terminated state 2022-05-12 14:59:22 -04:00
Jeff Mitchell 99a16dafc2 Leave cluster listener up when bad data is sent (#2073)
Leave cluster listener up when bad data is sent

Removing the ALPN muxer exposed the underlying listener directly to the
gRPC server, which means that a quirk of the ALPN muxer (not surfacing
errors on accept) turned into the gRPC server receiving errors on
accept, and it turns out if the error does not satisfy a special
temporary interface the listener will be closed.

The obviously better thing to do would be to let the listener close
itself if there was truly a fatal error rather than relying on
undocumented interfaces, but here we are.
2022-05-11 17:02:36 -04: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 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
Todd 687dd1bda6 Move the session cleanup job logic into the session package. (#2060)
* Move the session cleanup job logic into the session package.

This is part of a broader effort to more narrowly define the purpose of the internal/server directory to be for interacting with servers themselves.  Future changes will continue to remove things from this directory until the purpose of the directory is clearly working primarily with the boundary servers resource.
2022-05-05 10:29:30 -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
Zed 93ed076fdb Bump version and update changelog for 0.8.0 release (#2053) 2022-05-03 10:19:04 -04:00
Zed 9292fffa86 Bump version in preparation for 0.8.0 release (#2050) 2022-05-02 17:23:24 -04:00
irenarindos c6764e85d9 fix(session): Update session state transition trigger 2022-05-02 15:58:41 -04:00
Timothy Messier f00af362dc fix(session): Include where clause with order and limit
When applying the limit and order by, the where clause also needs to be
applied to yield the correct results. This can be seen with an example.

Assuming a data set where there are 100 sessions, with 10 sessions
belonging to a user with id `u_user1` and 90 sessions belonging to
`u_user2`. If the constructed query is like:

    select *
    from
        (select public_id from session limit 10) s,
        session_list ss
    where
        s.public_id = ss.public_id
        and s.user_id = 'u_user1'
    order by create_time asc;

The initial sub-query with the limit could return sessions only
belonging to `u_user2`, then it would apply the where clause and exclude
all of the rows.

Instead if the query is:

    with
    session_ids as (
        select public_id
        from sessions as s
        where
            s.user_id = 'u_user1'
        order by create_time asc
        limit 10
    )
    select *
    from session_list
    where
        session_list.public_id in (select * from session_ids)
    order by create_time asc;

The CTE applies the where clause ensuring that only sessions for
`u_user1` are used for the final select from the view.
Note that the CTE is use primarily for readability.

This also adds an index on `session (create_time)` to aide the query
planner in performing the order by.
2022-04-29 16:33:44 -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 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 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
Jeff Mitchell b41e983503 Reorder authz check for sessions (#2042)
* Reorder session authz checks

This implements a mechanism for service handlers to pass a repo
satisfying an interface into the scope IDs listing function. The purpose
of this interface is to allow the same function to perform authorization
checking against resources rather than requiring service handlers to
fetch all resources in the determined set of scopes and then perform
this checking. While this could be done in each service handler, this
approach centralizes the logic, which has the nice benefit of removing
some boilerplate from service handler list functions that have adapted
to it.

Tests haven't changed, which is expected -- the function should return
exactly what was being returned before, simply faster.
2022-04-29 16:33:43 -04:00
Todd a1cf3234ed url.PathEscape resource ids in the sdk before sending building a request. (#2035) 2022-04-27 08:13:46 -07:00
Todd 5603652d33 Make the {id} regexp less strict for identifying the "path" label value. (#2034)
Previously we were matching what boundary considers an id, but that is determined after requests are routed by grpc-gateway.
This changes the regexp to match any path segment to try to behave the same way that grpc-gateway would when assigning values
to the {id} variable declared in the protobuf.
2022-04-21 14:29:31 -07: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
Timothy Messier 3be5c44907 feat(target): Classify resources for audit events 2022-04-20 13:32:32 -04:00
Timothy Messier c8be4a9890 refact(target): Switch subtype attributes to oneof
This updates the target resources to use a oneof for attributes. This
allows requests to the targets service to leverage the new
subtypes.AttributeTransformerInterceptor so that attributes are strongly
typed prior to the service handler.
2022-04-20 13:32:32 -04:00
Johan Brandhorst-Satzkorn 8c452b0991 feat(authmethods): Add classification to all fields 2022-04-20 13:32:32 -04:00
Timothy Messier 2ade7f34a8 feat(users): Classify resources for audit events 2022-04-20 13:32:32 -04:00
Timothy Messier 006fa3a85a feat(session): Classify resources for audit events 2022-04-20 13:32:32 -04:00
Timothy Messier 38a3960047 feat(role): Classify resources for audit events 2022-04-20 13:32:32 -04:00
Timothy Messier 4599e64cab feat(event): Remove BOUNDARY_DEVELOPER_ENABLE_EVENTS env var 2022-04-20 13:32:32 -04:00
Timothy Messier 1af803780c feat(controller): Reorder interceptor stack
The new `subtype.AttributeTransformerInterceptor` can return an error if
it fails to transform the attributes. This is mainly if invalid
attribute fields were included for a particular subtype. This error case
used to be checked in the grpc service handler functions. However, now
that it is happening in the interceptor, the `errorInterceptor` needs to
be moved up in the stack so that it will process the response of the new
transformation interceptor.

The `errorInterceptor` used to be after the `auditRequestInterceptor`
and prior to the `auditResponseInterceptor`, meaning that the
`auditResponseInterceptor` would have access to the result of the
`errorInterceptor`. But it seems the `auditRequestInterceptor` does not
use or need any of the headers set by the `errorInterceptor` so it
should be safe to move the `errorInterceptor`. This is important since
the `subtype.AttributeTransformerInterceptor` needs to be before the
audit interceptors in the stack to properly transform requests/responses
so they can be audited with the complete classification information.
2022-04-20 13:32:32 -04:00
Timothy Messier 6ad9aba505 feat(credentialstore): Classify resources for audit events 2022-04-20 13:32:32 -04:00
Timothy Messier 9d3a57cbb0 refact(credentialstore): Switch subtype attributes to oneof
This updates the credential store resources to use a oneof for
attributes. This allows requests to the credential store service to
leverage the new subtypes.AttributeTransformerInterceptor so that
attributes are strongly typed prior to the service handler.
2022-04-20 13:32:32 -04:00
Timothy Messier 00e57b20a2 feat(credentiallibrary): Classify resources for audit events 2022-04-20 13:32:32 -04:00
Timothy Messier 3d4ba0389e refact(credentiallibrary): Switch subtype attributes to oneof
This updates the credential library resources to use a oneof for
attributes. This allows requests to the credential library service to
leverage the new subtypes.AttributeTransformerInterceptor so that
attributes are strongly typed prior to the service handler.
2022-04-20 13:32:32 -04:00
Timothy Messier 95315a3e0a feat(groups): Classify resources for audit events 2022-04-20 13:32:32 -04:00
Timothy Messier e2eca03d26 feat(managedgroups): Classify resources for audit events 2022-04-20 13:32:31 -04:00
Timothy Messier 5d6cb0009d refact(managed-groups): Switch subtype attributes to oneof
This updates the credential store resources to use a oneof for
attributes. This allows requests to the credential store service to
leverage the new subtypes.AttributeTransformerInterceptor so that
attributes are strongly typed prior to the service handler.
2022-04-20 13:32:31 -04:00
Timothy Messier 9643f7af76 test(managedgroups): Add api tests for managed-groups endpoints 2022-04-20 13:32:31 -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
Timothy Messier 6b95d5f1fb doc(classification): Add initial rubric 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
Timothy Messier 0fc5cd5a33 test(account): Use require to prevent panic on test failure
If these assertions failed, then next assersions would result in a panic
when accessing the slice.
2022-04-20 13:32:31 -04:00
Timothy Messier 64ef193cfc test(account): Fix parallel validation tests 2022-04-20 13:32:31 -04:00