2024-04-09 17:21:21 +00:00
|
|
|
package action
|
2024-02-15 05:39:10 +00:00
|
|
|
|
|
|
|
import (
|
2024-04-09 17:21:21 +00:00
|
|
|
"context"
|
|
|
|
|
2024-02-15 05:39:10 +00: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 17:21:21 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
|
|
|
action "github.com/zitadel/zitadel/pkg/grpc/action/v3alpha"
|
2024-02-15 05:39:10 +00:00
|
|
|
)
|
|
|
|
|
2024-04-09 17:21:21 +00:00
|
|
|
var _ action.ActionServiceServer = (*Server)(nil)
|
2024-02-15 05:39:10 +00:00
|
|
|
|
|
|
|
type Server struct {
|
2024-04-09 17:21:21 +00:00
|
|
|
action.UnimplementedActionServiceServer
|
2024-02-26 10:49:43 +00:00
|
|
|
command *command.Commands
|
|
|
|
query *query.Queries
|
|
|
|
ListActionFunctions func() []string
|
|
|
|
ListGRPCMethods func() []string
|
|
|
|
ListGRPCServices func() []string
|
2024-02-15 05:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Config struct{}
|
|
|
|
|
|
|
|
func CreateServer(
|
|
|
|
command *command.Commands,
|
|
|
|
query *query.Queries,
|
2024-02-26 10:49:43 +00:00
|
|
|
listActionFunctions func() []string,
|
|
|
|
listGRPCMethods func() []string,
|
|
|
|
listGRPCServices func() []string,
|
2024-02-15 05:39:10 +00:00
|
|
|
) *Server {
|
|
|
|
return &Server{
|
2024-02-26 10:49:43 +00:00
|
|
|
command: command,
|
|
|
|
query: query,
|
|
|
|
ListActionFunctions: listActionFunctions,
|
|
|
|
ListGRPCMethods: listGRPCMethods,
|
|
|
|
ListGRPCServices: listGRPCServices,
|
2024-02-15 05:39:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) RegisterServer(grpcServer *grpc.Server) {
|
2024-04-09 17:21:21 +00:00
|
|
|
action.RegisterActionServiceServer(grpcServer, s)
|
2024-02-15 05:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) AppName() string {
|
2024-04-09 17:21:21 +00:00
|
|
|
return action.ActionService_ServiceDesc.ServiceName
|
2024-02-15 05:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) MethodPrefix() string {
|
2024-04-09 17:21:21 +00:00
|
|
|
return action.ActionService_ServiceDesc.ServiceName
|
2024-02-15 05:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) AuthMethods() authz.MethodMapping {
|
2024-04-09 17:21:21 +00:00
|
|
|
return action.ActionService_AuthMethods
|
2024-02-15 05:39:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) RegisterGateway() server.RegisterGatewayFunc {
|
2024-04-09 17:21:21 +00:00
|
|
|
return action.RegisterActionServiceHandler
|
|
|
|
}
|
|
|
|
|
|
|
|
func checkExecutionEnabled(ctx context.Context) error {
|
|
|
|
if authz.GetInstance(ctx).Features().Actions {
|
|
|
|
return nil
|
|
|
|
}
|
2024-05-04 09:55:57 +00:00
|
|
|
return zerrors.ThrowPreconditionFailed(nil, "ACTION-8o6pvqfjhs", "Errors.Action.NotEnabled")
|
2024-02-15 05:39:10 +00:00
|
|
|
}
|