Skip to content

Commit

Permalink
Kick off CRUD API & Minder API Authz (#4970)
Browse files Browse the repository at this point in the history
* add: kick off CRUD API & Minder API Authz

* fix: unused req param

* Register data source service in control plane server

Signed-off-by: Juan Antonio Osorio <[email protected]>

* Use ContextV2 in data sources

Signed-off-by: Juan Antonio Osorio <[email protected]>

---------

Signed-off-by: Juan Antonio Osorio <[email protected]>
Co-authored-by: Juan Antonio Osorio <[email protected]>
  • Loading branch information
teodor-yanev and JAORMX authored Nov 15, 2024
1 parent f117ed1 commit 9b7eaac
Show file tree
Hide file tree
Showing 12 changed files with 8,662 additions and 6,805 deletions.
106 changes: 106 additions & 0 deletions docs/docs/ref/proto.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions internal/authz/model/minder.fga
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@ type project
define profile_status_get: viewer

define entity_reconciliation_task_create: editor

define data_source_get: viewer
define data_source_create: admin
define data_source_update: admin
define data_source_delete: admin
2 changes: 1 addition & 1 deletion internal/authz/model/minder.generated.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions internal/controlplane/handlers_data_source.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// SPDX-FileCopyrightText: Copyright 2024 The Minder Authors
// SPDX-License-Identifier: Apache-2.0

package controlplane

import (
"context"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/mindersec/minder/internal/flags"
minderv1 "github.com/mindersec/minder/pkg/api/protobuf/go/minder/v1"
)

// CreateDataSource creates a data source
func (s *Server) CreateDataSource(ctx context.Context,
_ *minderv1.CreateDataSourceRequest) (*minderv1.CreateDataSourceResponse, error) {

if !flags.Bool(ctx, s.featureFlags, flags.DataSources) {
return nil, status.Errorf(codes.Unavailable, "DataSources feature is disabled")
}

return &minderv1.CreateDataSourceResponse{}, nil
}

// GetDataSourceById retrieves a data source by ID
func (s *Server) GetDataSourceById(ctx context.Context,
_ *minderv1.GetDataSourceByIdRequest) (*minderv1.GetDataSourceByIdResponse, error) {

if !flags.Bool(ctx, s.featureFlags, flags.DataSources) {
return nil, status.Errorf(codes.Unavailable, "DataSources feature is disabled")
}

return &minderv1.GetDataSourceByIdResponse{}, nil
}

// ListDataSources lists all data sources
func (s *Server) ListDataSources(ctx context.Context,
_ *minderv1.ListDataSourcesRequest) (*minderv1.ListDataSourcesResponse, error) {

if !flags.Bool(ctx, s.featureFlags, flags.DataSources) {
return nil, status.Errorf(codes.Unavailable, "DataSources feature is disabled")
}

return &minderv1.ListDataSourcesResponse{}, nil
}

// UpdateDataSource updates a data source
func (s *Server) UpdateDataSource(ctx context.Context,
_ *minderv1.UpdateDataSourceRequest) (*minderv1.UpdateDataSourceResponse, error) {

if !flags.Bool(ctx, s.featureFlags, flags.DataSources) {
return nil, status.Errorf(codes.Unavailable, "DataSources feature is disabled")
}

return &minderv1.UpdateDataSourceResponse{}, nil
}

// DeleteDataSource deletes a data source
func (s *Server) DeleteDataSource(ctx context.Context,
_ *minderv1.DeleteDataSourceRequest) (*minderv1.DeleteDataSourceResponse, error) {

if !flags.Bool(ctx, s.featureFlags, flags.DataSources) {
return nil, status.Errorf(codes.Unavailable, "DataSources feature is disabled")
}

return &minderv1.DeleteDataSourceResponse{}, nil
}
8 changes: 8 additions & 0 deletions internal/controlplane/register_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ func RegisterGatewayHTTPHandlers(ctx context.Context, gwmux *runtime.ServeMux, g
if err := pb.RegisterInviteServiceHandlerFromEndpoint(ctx, gwmux, grpcAddress, opts); err != nil {
log.Fatal().Err(err).Msg("failed to register gateway")
}

// Register the DataSource service
if err := pb.RegisterDataSourceServiceHandlerFromEndpoint(ctx, gwmux, grpcAddress, opts); err != nil {
log.Fatal().Err(err).Msg("failed to register gateway")
}
}

// RegisterGRPCServices registers the GRPC services
Expand Down Expand Up @@ -113,4 +118,7 @@ func RegisterGRPCServices(s *Server) {

// Register the InviteService service
pb.RegisterInviteServiceServer(s.grpcServer, s)

// Register the DataSource service
pb.RegisterDataSourceServiceServer(s.grpcServer, s)
}
1 change: 1 addition & 0 deletions internal/controlplane/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ type Server struct {
pb.UnimplementedProvidersServiceServer
pb.UnimplementedEvalResultsServiceServer
pb.UnimplementedInviteServiceServer
pb.UnimplementedDataSourceServiceServer
}

// NewServer creates a new server instance
Expand Down
2 changes: 2 additions & 0 deletions internal/flags/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ const (
VulnCheckErrorTemplate Experiment = "vulncheck_error_template"
// AlternateMessageDriver enables an an alternate message driver.
AlternateMessageDriver Experiment = "alternate_message_driver"
// DataSources enables data sources management.
DataSources Experiment = "data_sources"
)
Loading

0 comments on commit 9b7eaac

Please sign in to comment.