Add session recording service stuff

This commit is contained in:
Todd authored and Timothy Messier committed 2023-05-31 12:18:17 +00:00
1 parent 281989e595
commit cfe0dc08d9
10 files changed
+242 -197

No files matched your search

+16
View File
@@ -35,6 +35,7 @@ import (
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/managed_groups"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/roles"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/scopes"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/session_recordings"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/sessions"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/storage_buckets"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/targets"
@@ -201,6 +202,18 @@ func (c *Controller) registerGrpcServices(s *grpc.Server) error {
}
services.RegisterStorageBucketServiceServer(s, sbs)
}
if _, ok := currentServices[services.SessionRecordingService_ServiceDesc.ServiceName]; !ok {
srs, err := session_recordings.NewServiceFn(
c.baseContext,
c.IamRepoFn,
c.workerStatusGracePeriod,
c.kms,
c.ControllerExtension)
if err != nil {
return fmt.Errorf("failed to create session recording handler service: %w", err)
}
services.RegisterSessionRecordingServiceServer(s, srs)
}
if _, ok := currentServices[services.TargetService_ServiceDesc.ServiceName]; !ok {
ts, err := targets.NewService(
c.baseContext,
@@ -348,6 +361,9 @@ func registerGrpcGatewayEndpoints(ctx context.Context, gwMux *runtime.ServeMux,
if err := services.RegisterStorageBucketServiceHandlerFromEndpoint(ctx, gwMux, gatewayTarget, dialOptions); err != nil {
return fmt.Errorf("failed to register storage bucket handler: %w", err)
}
if err := services.RegisterSessionRecordingServiceHandlerFromEndpoint(ctx, gwMux, gatewayTarget, dialOptions); err != nil {
return fmt.Errorf("failed to register session recording handler: %w", err)
}
return nil
}
@@ -20,6 +20,7 @@ import (
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/groups"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/host_catalogs"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/roles"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/session_recordings"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/sessions"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/storage_buckets"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/targets"
@@ -68,24 +69,26 @@ var (
scopeCollectionTypeMapMap = map[string]map[resource.Type]action.ActionSet{
scope.Global.String(): {
resource.AuthMethod: authmethods.CollectionActions,
resource.StorageBucket: storage_buckets.CollectionActions,
resource.AuthToken: authtokens.CollectionActions,
resource.Group: groups.CollectionActions,
resource.Role: roles.CollectionActions,
resource.Scope: CollectionActions,
resource.User: users.CollectionActions,
resource.Worker: workers.CollectionActions,
resource.AuthMethod: authmethods.CollectionActions,
resource.StorageBucket: storage_buckets.CollectionActions,
resource.AuthToken: authtokens.CollectionActions,
resource.Group: groups.CollectionActions,
resource.Role: roles.CollectionActions,
resource.Scope: CollectionActions,
resource.User: users.CollectionActions,
resource.Worker: workers.CollectionActions,
resource.SessionRecording: session_recordings.CollectionActions,
},
scope.Org.String(): {
resource.AuthMethod: authmethods.CollectionActions,
resource.StorageBucket: storage_buckets.CollectionActions,
resource.AuthToken: authtokens.CollectionActions,
resource.Group: groups.CollectionActions,
resource.Role: roles.CollectionActions,
resource.Scope: CollectionActions,
resource.User: users.CollectionActions,
resource.AuthMethod: authmethods.CollectionActions,
resource.StorageBucket: storage_buckets.CollectionActions,
resource.AuthToken: authtokens.CollectionActions,
resource.Group: groups.CollectionActions,
resource.Role: roles.CollectionActions,
resource.Scope: CollectionActions,
resource.User: users.CollectionActions,
resource.SessionRecording: session_recordings.CollectionActions,
},
scope.Project.String(): {
@@ -0,0 +1,64 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package session_recordings
import (
"context"
"sync/atomic"
"github.com/hashicorp/boundary/internal/daemon/controller/common"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
intglobals "github.com/hashicorp/boundary/internal/globals"
"github.com/hashicorp/boundary/internal/kms"
"github.com/hashicorp/boundary/internal/types/action"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
var (
// IdActions contains the set of actions that can be performed on
// individual resources
IdActions = action.ActionSet{
action.NoOp,
action.Read,
action.Download,
}
// CollectionActions contains the set of actions that can be performed on
// this collection
CollectionActions = action.ActionSet{
action.List,
}
)
// NewServiceFn returns a storage bucket service which is not implemented in OSS
var NewServiceFn = func(ctx context.Context,
iamRepoFn common.IamRepoFactory,
workerStatusGracePeriod *atomic.Int64,
kms *kms.Kms,
controllerExt intglobals.ControllerExtension,
) (pbs.SessionRecordingServiceServer, error) {
return Service{}, nil
}
type Service struct {
pbs.UnimplementedSessionRecordingServiceServer
}
var _ pbs.SessionRecordingServiceServer = (*Service)(nil)
// GetSessionRecording implements the interface pbs.SessionRecordingServiceServer.
func (s Service) GetSessionRecording(context.Context, *pbs.GetSessionRecordingRequest) (*pbs.GetSessionRecordingResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "session recordings are an Enterprise-only feature")
}
// ListSessionRecordings implements the interface pbs.SessionRecordingServiceServer.
func (s Service) ListSessionRecordings(context.Context, *pbs.ListSessionRecordingsRequest) (*pbs.ListSessionRecordingsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "session recordings are an Enterprise-only feature")
}
// Download implements the interface pbs.SessionRecordingServiceServer.
func (s Service) Download(*pbs.DownloadRequest, pbs.SessionRecordingService_DownloadServer) error {
return status.Errorf(codes.Unimplemented, "session recordings are an Enterprise-only feature")
}
@@ -43,7 +43,7 @@ var NewServiceFn = func(ctx context.Context,
}
type Service struct {
pbs.UnsafeStorageBucketServiceServer
pbs.UnimplementedStorageBucketServiceServer
}
var _ pbs.StorageBucketServiceServer = (*Service)(nil)