diff --git a/internal/daemon/controller/handler.go b/internal/daemon/controller/handler.go index f2f96f4a4c..99a4f7eb0f 100644 --- a/internal/daemon/controller/handler.go +++ b/internal/daemon/controller/handler.go @@ -201,7 +201,9 @@ func (c *Controller) registerGrpcServices(s *grpc.Server) error { c.VaultCredentialRepoFn, c.StaticCredentialRepoFn, c.downstreamWorkers, - c.workerStatusGracePeriod) + c.workerStatusGracePeriod, + c.ControllerExtension, + ) if err != nil { return fmt.Errorf("failed to create target handler service: %w", err) } diff --git a/internal/daemon/controller/handlers/targets/target_service.go b/internal/daemon/controller/handlers/targets/target_service.go index fd3418e2fe..f443be4697 100644 --- a/internal/daemon/controller/handlers/targets/target_service.go +++ b/internal/daemon/controller/handlers/targets/target_service.go @@ -24,6 +24,7 @@ import ( "github.com/hashicorp/boundary/internal/db/timestamp" "github.com/hashicorp/boundary/internal/errors" pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services" + intglobals "github.com/hashicorp/boundary/internal/globals" "github.com/hashicorp/boundary/internal/host" "github.com/hashicorp/boundary/internal/host/plugin" "github.com/hashicorp/boundary/internal/host/static" @@ -119,6 +120,7 @@ type Service struct { downstreams common.Downstreamers kmsCache *kms.Kms workerStatusGracePeriod *atomic.Int64 + controllerExt intglobals.ControllerExtension } var _ pbs.TargetServiceServer = (*Service)(nil) @@ -137,8 +139,12 @@ func NewService( staticCredRepoFn common.StaticCredentialRepoFactory, downstreams common.Downstreamers, workerStatusGracePeriod *atomic.Int64, + controllerExt intglobals.ControllerExtension, ) (Service, error) { const op = "targets.NewService" + if kmsCache == nil { + return Service{}, errors.New(ctx, errors.InvalidParameter, op, "missing kms repo") + } if repoFn == nil { return Service{}, errors.New(ctx, errors.InvalidParameter, op, "missing target repository") } @@ -175,6 +181,7 @@ func NewService( downstreams: downstreams, kmsCache: kmsCache, workerStatusGracePeriod: workerStatusGracePeriod, + controllerExt: controllerExt, }, nil } diff --git a/internal/daemon/controller/handlers/targets/tcp/target_service_test.go b/internal/daemon/controller/handlers/targets/tcp/target_service_test.go index 9653998313..e488445335 100644 --- a/internal/daemon/controller/handlers/targets/tcp/target_service_test.go +++ b/internal/daemon/controller/handlers/targets/tcp/target_service_test.go @@ -113,7 +113,7 @@ func testService(t *testing.T, ctx context.Context, conn *db.DB, kms *kms.Kms, w staticCredRepoFn := func() (*credstatic.Repository, error) { return credstatic.NewRepository(context.Background(), rw, rw, kms) } - return targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod) + return targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod, nil) } func TestGet(t *testing.T) { @@ -2594,7 +2594,7 @@ func TestAuthorizeSession(t *testing.T) { statusGracePeriod := new(atomic.Int64) statusGracePeriod.Store(int64(server.DefaultLiveness)) - s, err := targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod) + s, err := targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod, nil) require.NoError(t, err) for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { @@ -2763,7 +2763,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) { statusGracePeriod := new(atomic.Int64) statusGracePeriod.Store(int64(server.DefaultLiveness)) - s, err := targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod) + s, err := targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod, nil) require.NoError(t, err) hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0] @@ -3336,7 +3336,7 @@ func TestAuthorizeSession_Errors(t *testing.T) { statusGracePeriod := new(atomic.Int64) statusGracePeriod.Store(int64(server.DefaultLiveness)) - s, err := targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod) + s, err := targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod, nil) require.NoError(t, err) // Authorized user gets full permissions