2023-04-11 13:37:42 +00:00
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
2023-05-24 18:29:58 +00:00
|
|
|
"context"
|
|
|
|
|
2023-04-11 13:37:42 +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"
|
2023-04-25 07:02:29 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/crypto"
|
2024-01-17 09:00:10 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
2023-04-11 13:37:42 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/query"
|
2024-07-26 20:39:55 +00:00
|
|
|
"github.com/zitadel/zitadel/pkg/grpc/user/v2"
|
2023-04-11 13:37:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ user.UserServiceServer = (*Server)(nil)
|
|
|
|
|
|
|
|
type Server struct {
|
|
|
|
user.UnimplementedUserServiceServer
|
2023-04-25 07:02:29 +00:00
|
|
|
command *command.Commands
|
|
|
|
query *query.Queries
|
|
|
|
userCodeAlg crypto.EncryptionAlgorithm
|
2023-05-24 18:29:58 +00:00
|
|
|
idpAlg crypto.EncryptionAlgorithm
|
|
|
|
idpCallback func(ctx context.Context) string
|
2023-09-29 09:26:14 +00:00
|
|
|
samlRootURL func(ctx context.Context, idpID string) string
|
2024-01-17 09:00:10 +00:00
|
|
|
|
|
|
|
assetAPIPrefix func(context.Context) string
|
|
|
|
|
|
|
|
checkPermission domain.PermissionCheck
|
2023-04-11 13:37:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Config struct{}
|
|
|
|
|
2023-05-24 18:29:58 +00:00
|
|
|
func CreateServer(
|
|
|
|
command *command.Commands,
|
|
|
|
query *query.Queries,
|
|
|
|
userCodeAlg crypto.EncryptionAlgorithm,
|
|
|
|
idpAlg crypto.EncryptionAlgorithm,
|
|
|
|
idpCallback func(ctx context.Context) string,
|
2023-09-29 09:26:14 +00:00
|
|
|
samlRootURL func(ctx context.Context, idpID string) string,
|
2024-01-17 09:00:10 +00:00
|
|
|
assetAPIPrefix func(ctx context.Context) string,
|
|
|
|
checkPermission domain.PermissionCheck,
|
2023-05-24 18:29:58 +00:00
|
|
|
) *Server {
|
2023-04-11 13:37:42 +00:00
|
|
|
return &Server{
|
2024-01-17 09:00:10 +00:00
|
|
|
command: command,
|
|
|
|
query: query,
|
|
|
|
userCodeAlg: userCodeAlg,
|
|
|
|
idpAlg: idpAlg,
|
|
|
|
idpCallback: idpCallback,
|
|
|
|
samlRootURL: samlRootURL,
|
|
|
|
assetAPIPrefix: assetAPIPrefix,
|
|
|
|
checkPermission: checkPermission,
|
2023-04-11 13:37:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) RegisterServer(grpcServer *grpc.Server) {
|
|
|
|
user.RegisterUserServiceServer(grpcServer, s)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) AppName() string {
|
|
|
|
return user.UserService_ServiceDesc.ServiceName
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) MethodPrefix() string {
|
|
|
|
return user.UserService_ServiceDesc.ServiceName
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) AuthMethods() authz.MethodMapping {
|
|
|
|
return user.UserService_AuthMethods
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) RegisterGateway() server.RegisterGatewayFunc {
|
|
|
|
return user.RegisterUserServiceHandler
|
|
|
|
}
|