2024-04-09 19:21:21 +02:00
|
|
|
package action
|
2024-02-15 06:39:10 +01:00
|
|
|
|
|
|
|
import (
|
2024-04-09 19:21:21 +02:00
|
|
|
"context"
|
|
|
|
|
2024-02-15 06:39:10 +01:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/grpc/server"
|
|
|
|
"github.com/zitadel/zitadel/internal/command"
|
|
|
|
"github.com/zitadel/zitadel/internal/query"
|
2024-04-09 19:21:21 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
|
|
|
action "github.com/zitadel/zitadel/pkg/grpc/action/v3alpha"
|
2024-02-15 06:39:10 +01:00
|
|
|
)
|
|
|
|
|
2024-04-09 19:21:21 +02:00
|
|
|
var _ action.ActionServiceServer = (*Server)(nil)
|
2024-02-15 06:39:10 +01:00
|
|
|
|
|
|
|
type Server struct {
|
2024-04-09 19:21:21 +02:00
|
|
|
action.UnimplementedActionServiceServer
|
2024-02-26 11:49:43 +01:00
|
|
|
command *command.Commands
|
|
|
|
query *query.Queries
|
|
|
|
ListActionFunctions func() []string
|
|
|
|
ListGRPCMethods func() []string
|
|
|
|
ListGRPCServices func() []string
|
2024-02-15 06:39:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type Config struct{}
|
|
|
|
|
|
|
|
func CreateServer(
|
|
|
|
command *command.Commands,
|
|
|
|
query *query.Queries,
|
2024-02-26 11:49:43 +01:00
|
|
|
listActionFunctions func() []string,
|
|
|
|
listGRPCMethods func() []string,
|
|
|
|
listGRPCServices func() []string,
|
2024-02-15 06:39:10 +01:00
|
|
|
) *Server {
|
|
|
|
return &Server{
|
2024-02-26 11:49:43 +01:00
|
|
|
command: command,
|
|
|
|
query: query,
|
|
|
|
ListActionFunctions: listActionFunctions,
|
|
|
|
ListGRPCMethods: listGRPCMethods,
|
|
|
|
ListGRPCServices: listGRPCServices,
|
2024-02-15 06:39:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) RegisterServer(grpcServer *grpc.Server) {
|
2024-04-09 19:21:21 +02:00
|
|
|
action.RegisterActionServiceServer(grpcServer, s)
|
2024-02-15 06:39:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) AppName() string {
|
2024-04-09 19:21:21 +02:00
|
|
|
return action.ActionService_ServiceDesc.ServiceName
|
2024-02-15 06:39:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) MethodPrefix() string {
|
2024-04-09 19:21:21 +02:00
|
|
|
return action.ActionService_ServiceDesc.ServiceName
|
2024-02-15 06:39:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) AuthMethods() authz.MethodMapping {
|
2024-04-09 19:21:21 +02:00
|
|
|
return action.ActionService_AuthMethods
|
2024-02-15 06:39:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) RegisterGateway() server.RegisterGatewayFunc {
|
2024-04-09 19:21:21 +02:00
|
|
|
return action.RegisterActionServiceHandler
|
|
|
|
}
|
|
|
|
|
|
|
|
func checkExecutionEnabled(ctx context.Context) error {
|
|
|
|
if authz.GetInstance(ctx).Features().Actions {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return zerrors.ThrowPreconditionFailed(nil, "SCHEMA-141bwx3lef", "Errors.action.NotEnabled")
|
2024-02-15 06:39:10 +01:00
|
|
|
}
|