Commit Graph
412 Commits
Author SHA1 Message Date
7c4451dc73 Bug: fix groups in children scopes being filtered out by grants (#5418)
* add utility functions for grants tests

* use passed in scopeID to create user

* add test for groups list

* groups: set ParentScopeId before FetchActionSetForId

* add comment to TestRoleGrantsForToken

* lint and ran make gen

* fix import groups

* add an additional test case

* remove print

* changelog

* fix(alias): set parent scope id for alias resource (#5434)

set the `ParentScopeId` before fetching authorized actions for alias

* fix(worker): set parent scope id for worker resource (#5435)

set the `ParentScopeId` before fetching authorized actions for worker

* fix(user): children scopes being filtered out by grants for user (#5436)

* fix(user): children scopes being filtered out by grants for user

Resources are being filtered out due to missing ParentScopeId when constructing Resource to pass into authResults.FetchActionSetForId.

* fix(scope): set parent scope id for worker resource (#5439)

set the `ParentScopeId` before fetching authorized actions for worker

* fix(target): set parent scope id for target resource (#5447)

set the `ParentScopeId` before fetching authorized actions for target

* fix(roles): set parent scope id for roles resource (#5452)

* fix(roles): set parent scope id for roles resource

set the `ParentScopeId` before fetching authorized actions for role resource

* test(managed-group): add grants test coverage (#5453)

* fix(managed-group): set parent scope id for managed-group resource

set the ParentScopeId before fetching authorized actions for managed resource

* fix(host): set parent scope id for host resource (#5455)

set the `ParentScopeId` before fetching authorized actions for host resource

* fix(host-set): set parent scope id for host-set resource (#5456)

set the ParentScopeId before fetching authorized actions for host-set resource

* fix(host-catalog): set parent scope id for host-catalog resource (#5457)

set the ParentScopeId before fetching authorized actions for host-catalog resource

* fix(credential-store): set parent scope id for credential-store resource (#5458)

set the ParentScopeId before fetching authorized actions for credential-store resource

* fix(authmethods): set parent scope ID for auth methods resource (#5448)

* handlers/authmethods: fix children permission

* documentation

* formatting

* fix(credential): set parent scope id for credential resource (#5459)

set the `ParentScopeId` before fetching authorized actions for credential resource

* fix(accounts): bug grants filter children accounts (#5431)

* handlers/accounts: fix children grants filtering out results unexpectedly

* make gen

* fix(authtokens): set parent scope ID for auth token resource (#5451)

* fix authtokens not passing children scope ID

* make gen

* fix(credential-libraries): set parent scope ID (#5463)

* fix(common) set parent ID before fetching action setsparent ID before fetching action sets (#5467)

* fix(common) set parent ID before fetching action sets

* make gen

* additional test

* rename test

* more tests

* remove duplicate test

* make gen

* Update CHANGELOG.md

Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>

---------

Co-authored-by: Elim Tsiagbey <elim.tsiagbey@hashicorp.com>
Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2025-01-24 10:23:33 -08:00
April Ayres b18b586ec8 add noOp license validator function (#5468) 2025-01-23 11:55:11 -08:00
Johan Brandhorst-Satzkorn 40cb9f5c9e Restrict concurrent password hashes (#5437)
* internal/auth/password: add resizable pool

The resizable pool wraps the permit pool with a mutex
to allow it to be resized at runtime.

* internal/auth/password: add concurrency limit

The default concurrency limit is 1, and it can be
set using the SetHashingPermits function.

* internal/cmd/config: allow configuring hashing limits

The new concurrent_password_hash_workers configuration
value can be used to loosen the constraints on the
userpass auth method hashing operation.

* internal/cmd: set password hashing constraints

Sets the password hashing concurrency constraints on
startup and config reload.

* CHANGELOG: add notice about password concurrency limit
2025-01-22 13:31:42 -08:00
Irena Rindos dfe4f91be3 refactor(server): refactor worker tags (#5445)
* refactor(server): refactor worker tags
2025-01-22 13:03:55 -05:00
Johan Brandhorst-SatzkornandDamian Debkowski ec0a3f964b Worker status refactor (#5417)
* oss: feat(proto): statistics rpc added to server coordination service

* oss: feat(session): add update statistics status service

* oss: feat(handlers): add Statistics method to worker service server

* oss: feat(worker): add statistics ticking

* oss: internal/proto: define the new RoutingInfo RPC

* oss: internal/server: repository changes for RoutingInfo RPC

* oss: internal/daemon: add RoutingInfo handler to worker service

The new RoutingInfo RPC is used to get information from the worker
that is used to make routing decisions on the controller. It also
handles the initial request from the worker.

* oss: feat(db): server_worker_session_info table

* oss: feat(proto): session info rpc for server coordination service

* oss: feat(server): worker session info request data type

* oss: feat(worker): session info ticker

* oss: feat(handler): server coordination handler for session info

* oss: feat(session): utilize session info request time for session cleanup

* oss: proto: fix some gotags comments

Some of these fields were missing comments, while others had
incorrectly formatted comments.

* oss: worker: send connection status to server

This is required for the correct tracking of orphaned connections

* oss: internal/daemon/worker: add function to wait for Statistics RPC

* oss: internal/daemon/worker: add routing info RPC

The new RoutingInfo RPC replaces part of the Status RPC,
namely the part which is used by the controller and worker
to perform decisions around the establishment of new sessions
and new worker connections.

* oss: internal/daemon/worker: remove unnecessary error check

* oss: internal/daemon/worker: lock access to config and upstreams

The new confLock protects access to the conf value and to the
addressReceivers slice.

* oss: worker: replace Status RPC with RoutingInfo

* oss: worker: deprecate the Status RPC and related types

The Status RPC and related messages have been replaced
by the RoutingInfo/SessionInfo/Statistics RPCs. The controller
will continue to support the Status RPC until two new minor
versions have been released.

* oss: internal/event: add default deny for new worker RPCs

* oss: internal/daemon/worker: allow RPC interval to be set

The new SessionInfo/RoutingInfo/Statistics RPCs run at
long intervals, which make some of our cluster tests take
a long time to complete. This allows their interval to be
configured in tests.

* oss: all: use TestWorkerRPCInterval in slow tests

This should speed up these tests significantly.

* oss: internal/tests/cluster: reset sys eventer in test

---------

Co-authored-by: Damian Debkowski <damian.debkowski@hashicorp.com>
2025-01-09 10:26:37 -08:00
846c849589 Worker Domain Refactor (#5338)
* feat(server): Refactor LookupWorkerByName to be a test method

* feat(server): Split worker tags table

* refact(worker): Export api and config tags

* refact(server): Return worker id from UpsertWorkerStatus

* refact(server): Create ListWorkerStorageBucketUpdates domain function

* refact(server): Use dedicated HCPb-worker list func

* refact(server): Create ConnectionRoute domain function

* refact(handlers): Move worker selection logic to internal/server package

This commit moves all the logic to select a worker to handle a session
to the internal/server package. Most functions were moved to this
package with no changes, however, there are a couple of notable
exceptions:

- Given that we don't use GRPC errors in repos, all errors were adjusted
  to use the internal/errors package instead.
- StorageBucketFilterCredIdFn is now used to prevent the internal/server
  package from importing internal/storage/plugin, which would cause a
  dep cycle. Callers of SelectSessionWorkers must implement this func
  which is responsible for returning a storage bucket's worker filter as
  well as its associated credential id.
- authorizeSessionWithWorkerFilter now receives an
  internal/server.(*Repository) object when called. This is transparent
  to SelectSessionWorkers callers as it is handled internally.

* feat(server): Add FilteredWithFeatures fn and new server options

* refact(server): create new list and lookup worker queries

* test(server): Add WorkerList unit tests

* feat(server): Implement WorkerList randomness using crypto/rand pkg

* chore(db): add index to server_worker table

* refact(server): prefix test method with Test

* refact(server): rename Downstreamers interface to Graph

* chore(server): unexport and rename method

* chore: add doc string to WorkerAddress (#5420)

---------

Co-authored-by: Irena Rindos <irenarindos@users.noreply.github.com>
Co-authored-by: irenarindos <irena.rindos@gmail.com>
2025-01-08 15:18:03 +00:00
Damian Debkowski 868d7b8a2d test(daemon): remove tests with multihop (#5397) 2024-12-30 12:21:52 -08:00
David Kanney 2342e4b644 fix(target): Assign session connection limit to SessionAuthorization.ConnectionLimit (#5396)
* fix(target): Assign session connection limit to SessionAuthorization.ConnectionLimit

* test(target): Update TestAuthorizeSession & TestAuthorizeSessionTypedCredentials to check session connection limit
2024-12-30 14:16:39 -05:00
Damian Debkowski 98bb4c8c31 test(cluster): split tests between parallel and sequential packages (#5390) 2024-12-20 13:53:37 -08:00
David Kanney f62e67584e chore: Clarify GrantHash behavior when there are no GrantTuples (#5334)
* chore: Simplify appending

* test(grants): De-dupe hash comparison

* chore(grants): Remove TODO & add clarifying comment

* test(grants): Add test cases to enforce empty grants behavior
2024-12-06 16:45:38 -05:00
Johan Brandhorst-Satzkorn a2be306eb4 More managed groups limit fixes (#5245)
* internal/handlers/managed_groups: ensure membership lookup is unlimited

Previously, we would only show the first 10,000 members in the group,
giving the impression that a complete list was performed. Now we
list all members.

* internal/handlers/accounts: ensure group lookup is unlimited

Previously, we would only show the first 10,000 managed group
memberships. Now we list all group memberships of an account.
2024-11-15 10:27:20 -08:00
Elim Tsiagbey 514bcc19f6 feat(gcp): add GCP plugin (#5229)
Add GCP as a supported plugin for dynamic host catalogs
2024-11-08 11:09:29 -05:00
Hugo f227020b67 feat(scheduler): Use job table to select jobs to run
This commit changes the logic around selecting jobs to run. Before this,
Boundary used a view "job_jobs_to_run" which was a collation of all jobs
that were not running and scheduled to run. When jobs were requested to
run, Boundary would look at this view, grab a certain amount of jobs and
insert them into the "job_run" table. Importantly, while the amount of
jobs to be scheduled at once defaulted to 1 in the scheduler package,
this was entirely overriden in the controller package to -1 (no limit,
run all jobs that the query would return).

With this commit, Boundary now looks at the "job" table directly for
jobs to run, regardless of job run status. This was done to improve DB
performance as the view (which queried all "job_run" rows) was causing
significant DB contention.

Additionally, the option to limit job runs is now removed since it was
already hardcoded to -1 and not user-configurable anyways.

Should the need arise to implement this limit again, this will have to
be done in a different way since the new query does not account for
running jobs and limiting the rows returned after jobs are already
running would yield a no-op (the new query inserts nothing into
"job_run" if any given job is already running).
2024-11-06 16:15:49 +00:00
Hugo 27c432a748 feat(scheduler): Drop completed job runs as they complete
Before this change, upon the completion of a job run, the scheduler
would update a job_run entry with the completed status as well as the
number of objects affected by the run. Additionally, we then had a
cleaner job whose scope was deleting these completed entries from
job_run.

This commit changes this design to drop the cleaner job the and rolls
its functionality directly into the scheduler. Now, when any given job
run is complete, the scheduler will automatically delete it from the
job_run table itself.

In addition, the completed status has been removed as a valid status as
it is not set anymore.

This change follows a decision that given the data in these job_run
entries is already being deleted by the cleaner job, updating its state
when a job completes just to have it deleted is not efficient.
Additionally, no use-case for this data was surfaced.
2024-11-05 17:10:39 +00:00
daniandDamian Debkowski 62c41191ff [fix] allow IPv6 controllers, workers, and targets (#5221)
Co-authored-by: Damian Debkowski <damian.debkowski@hashicorp.com>
2024-11-01 13:27:40 -04:00
Irena Rindos 36158056d9 feat(workers): add VerifyKnownWorkers repo function (#5189) 2024-10-23 13:41:44 -04:00
Hugo b8046a3ef3 feat(handlers/host_catalogs): Support plugin host catalog worker filter 2024-09-30 21:24:18 +01:00
Jeff Mitchell 62d4f8453b Don't explode grants from the DB (#5104)
This removes the Cartesian product in the DB for GrantsForUser in favor
of returning the actual grant scope information and dealing with it in
application code.

(cherry picked from commit 913cd536823d73994acc4f4d833208c1cc05f91b)
2024-09-24 14:18:53 +00:00
Timothy Messier fe129b4268 fix(metrics): Fix matching logic for authorize session endpoint (#5121)
The target authorize session endpoint allows for alternative target
identifiers besides the public id. For this to function correctly, the
grpc gateway path definition for the endpoint deviates from the common
pattern used for other endpoints that include ids. When this change was
done, it was not accounted for in the logic used to capture the
prometheus metrics for api requests to this particular endpoint,
resulting in the metrics never incrementing for the authorize session
endpoint.

This fix updates the matching logic used for the metrics to ensure that
the metrics are incremented for this endpoint.

See: c149bc4a79
2024-09-19 14:02:41 -04:00
Johan Brandhorst-Satzkorn 41de35f2b1 internal/daemon/controller+worker: propagate downstream timeout (#5083)
Propagate the downstream worker timeout into the
downstream receiver and downstream ticker
so we have a configurable consistent timeout
value to use for worker to worker interactions.

Also change the atomic.Pointer to an atomic.Int64
for consistency with other values.
2024-09-11 12:19:11 -04:00
Jeff Mitchell 66af7dba98 Allow reloading some server timings (#5071)
Allows changing grace period and a few other things timing-related via
HUP instead of just a restart.

Tested manually via config changes and HUP.
2024-09-04 15:40:44 -04:00
David Bond 660e2063a4 Return HTTP 400 status for inactive OIDC auth methods (#5048)
This commit modifies the OIDC authentication start method to return a 400 (Bad Request) error
if a client attempts to start the authentication flow against an OIDC auth method that is set to
inactive. This is something we noticed in our error logs in HCP Boundary that is impacting our
SLOs.

Previously this returned its own error code which is mapped to a 500 response. Tests have been updated
to catch this new scenario.

Signed-off-by: David Bond <davidsbond93@gmail.com>
2024-08-30 16:33:18 +01:00
Elim Tsiagbey 306c722750 feat: Add support for capturing URL actions in request info (#5044)
* feat: Add support for capturing URL actions in request info

- Pass request context to services to validate actions.
- Validate actions for auth methods during authentication. `/v1/auth-methods/{{AUTH_METHOD_ID}}:authenticate:callback` is currently only supported on `OIDC` auth methods. An error is thrown if `:callback` is not supported
2024-08-29 17:14:42 -04:00
Elim Tsiagbey 84707c04cb feat: Disable path length fallback (#5050)
Add `WithDisablePathLengthFallback()` runtime option to the grpc-gateway mux HTTP server. This prevents the issue where the request method can be overridden with a `X-HTTP-Method-Override` header.
2024-08-28 09:30:05 -04:00
Johan Brandhorst-Satzkorn 96688b36d5 internal/daemon: simplify time update tests (#5041)
Using time.After makes the intent clearer
2024-08-27 11:00:04 -07:00
Elim Tsiagbey 123286cf94 feat: Validate LDAP URL port number (#5046)
Add validation for the port number in LDAP URLs. If a port number is provided, it is checked to ensure it is a valid integer and within the valid range. This validation helps prevent errors when configuring LDAP authentication.
2024-08-27 11:27:14 -04:00
Elim Tsiagbey e6d355b65a fix: constant-time comparison of grpc-gateway tickets (#5031)
Update GRPC Gateway tickets to compare tickets in constant-time
2024-08-21 12:26:22 -04:00
Sorawis Nilparuk (Bo) 350ac90a57 implement configurable getDownstreamWorker timeout (#5007)
* implement configurable getDownstreamWorker timeout

* add parsing test

* typos

* fix tests

* fix worker tests

* 0 is a valid value
2024-08-13 14:27:39 -07:00
Hugo 903039e885 fix(daemon): Return 404 if alias interceptor ResolveRequestIds fails (#5006) 2024-08-13 14:24:01 +01:00
Damian Debkowski c0cf5c4e1b feat(api): return remote storage states for worker 2024-07-17 14:23:11 -04:00
Damian Debkowski 00e4c5448b feat: workers filtered by sbc state 2024-07-17 14:23:11 -04:00
Damian Debkowski 9bc5e492f6 feat(sbc): add upsert worker storage bucket job 2024-07-17 14:23:11 -04:00
Damian Debkowski 162a857a29 feat(sbc): Add domain changes for SBC 2024-07-17 14:23:11 -04:00
Jeff MitchellandJohan Brandhorst-Satzkorn 4e0c2d79ac Add grant scope IDs to role list (#4893)
This adds grant_scope_ids in the output of role listing. The lookup for grant scope IDs was changed to allow taking in a set of roles instead of just a single role, and the results are collated afterwards.

---------

Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2024-06-25 13:05:52 -04:00
Johan Brandhorst-SatzkornandJeff Mitchell c6f3c375f3 api: remove deprecated grant_scope_id field (#4886)
* api: remove deprecated grant_scope_id field

The grant_scope_id field was deprecated in 0.15.0, so we can remove
it for 0.17.0.

* Fix tests

* Fix more tests

* Remove an option and some related code that stuck around

* Fix bats tests

---------

Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
2024-06-17 12:09:33 -07:00
Jeff Mitchell d547e0d459 Add test ability to reinitialize worker auth roots on startup (#4895) 2024-06-17 12:26:55 -04:00
Irena RindosandDanielle Miu 61e7ab4738 Allow descriptions to contain newlines and other whitespace (#2599)
* Allow names and descriptions to contain newlines and other whitespace

* separate validate name from validate description

* update changelog

---------

Co-authored-by: Danielle Miu <29378233+DanielleMiu@users.noreply.github.com>
2024-06-06 13:03:42 -04:00
David Bond 0c25dbad13 Use appropriate gRPC error codes for OIDC (#4877)
This commit makes modifications to the OIDC request handlers to return appropriate gRPC
status codes on errors. Before this change, boundary presents the internal error codes to
clients. This causes problems for reverse proxies, as these status codes are mapped to
non-standard HTTP response codes which are ultimately all turned into 500 responses when
4xx status codes are more appropriate and descriptive of the error returned.

Some modifications in this commit include calls to `event.WriteError` so that the
internal error is written to the controller log for visibility. Comments about
potential duplicate logs are now removed as `event.WriteError` is not called when using
functions from the `handlers` package.

Signed-off-by: David Bond <davidsbond93@gmail.com>
2024-06-06 14:59:43 +01:00
Michael Li e18e3ab783 test: Fix tests due to time (#4855)
* test(billing): Calculate time deltas from a fixed time

Some time calculations are impacted when using the current day vs. the start of the month.

* test(db): Conditionally skip tests at end of month

Certain tests fail when run on the last day of the month because of edge cases in the setup of test data (for example, if today is May 31 and NZ time is June 1). This adds conditional logic to skip those tests when run on the last day of a month.

* CR: typo
2024-05-31 17:08:57 -04:00
Timothy Messier a2c529b9d1 fix(controller): Use max request duration cluster listener (#4805)
The cluster listener supports a `max_request_duration` option, and
defaults to 90 seconds. However, this configuration was not being use
when processing grpc requests from the listener. This meant that
requests from worker to controller could hang indefinitely and
contributed to the recently fixed issue with database connections being
stuck in `idle in transaction`.

This commit adds a grpc interceptor that ensures each request has a
deadline set to the max request duration for the listener.

Refs: 29cd7bc9d6
2024-05-17 11:59:50 -04:00
Irena Rindos 16d23fa55f bug(scopes): scopes list returns 500 without perms (#4731) 2024-04-26 11:55:30 -04:00
Todd 7df9144fbf Fix typos in request validation errors for aliases (#4671)
* Fix typos in request validation errors for aliases

* Add format validation for destination id field.
2024-04-19 07:49:11 -07:00
Todd 0d67b86543 Add ListResolvableAliases to the user service (#4609)
* Add ListResolvableAliases to the user service

There are a few non common ways this method uses our ACL
and grant system. A user is able to list resolvable
aliases for another user if they are granted permission
to do so. That means we had to load the grants for
the user being listed for and not the requester when
determining if an alias is able to resolve to a destination
for which the requested user has permission.

Similarly, the grant hash used for the list pagination
is required to be that of the user being listed and not
the requester.
2024-04-17 08:26:46 -07:00
dani 1a77e4da86 Boundary Plugin MinIO (#4621)
feat(storage): Add storage support for MinIO via new built-in plugin
2024-04-12 11:28:40 -04:00
Louis Ruch c376d06355 feat: Add support for correlationId 2024-04-11 09:08:45 -07:00
Elim Tsiagbey 2c140b1e09 feat: Local Storage State API & CLI
- add `local_storage_state` value to API & CLI
2024-04-05 16:47:22 -04:00
Elim Tsiagbey 3bef063c72 feat: Filter workers by local storage state function
- add functionality to filter worker by local storage state.
- add feature constraint for local storage state
2024-04-05 16:47:10 -04:00
Louis Ruch e9e3d7cad5 feat(session): Include session recording id in auth-session resp (#4593) 2024-04-03 17:54:37 -07:00
ToddandJohan Brandhorst-Satzkorn 55fe70e643 Change 404 errors for aliases to 401s (#4575)
* Change 404 errors for alias resolution to 401s
---------

Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2024-03-27 16:14:49 -07:00
Jeff Mitchell a4bafdf9f4 Remove unintended log statements (#4533) 2024-03-15 10:34:51 -04:00