forked from zitadel/zitadel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
82 lines (69 loc) · 2.08 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package admin
import (
"context"
"google.golang.org/grpc"
"github.com/dennigogo/zitadel/internal/admin/repository"
"github.com/dennigogo/zitadel/internal/admin/repository/eventsourcing"
"github.com/dennigogo/zitadel/internal/api/assets"
"github.com/dennigogo/zitadel/internal/api/authz"
"github.com/dennigogo/zitadel/internal/api/grpc/server"
"github.com/dennigogo/zitadel/internal/command"
"github.com/dennigogo/zitadel/internal/config/systemdefaults"
"github.com/dennigogo/zitadel/internal/crypto"
"github.com/dennigogo/zitadel/internal/query"
"github.com/dennigogo/zitadel/pkg/grpc/admin"
)
const (
adminName = "Admin-API"
)
var _ admin.AdminServiceServer = (*Server)(nil)
type Server struct {
admin.UnimplementedAdminServiceServer
database string
command *command.Commands
query *query.Queries
administrator repository.AdministratorRepository
assetsAPIDomain func(context.Context) string
userCodeAlg crypto.EncryptionAlgorithm
passwordHashAlg crypto.HashAlgorithm
}
type Config struct {
Repository eventsourcing.Config
}
func CreateServer(
database string,
command *command.Commands,
query *query.Queries,
sd systemdefaults.SystemDefaults,
repo repository.Repository,
externalSecure bool,
userCodeAlg crypto.EncryptionAlgorithm,
) *Server {
return &Server{
database: database,
command: command,
query: query,
administrator: repo,
assetsAPIDomain: assets.AssetAPI(externalSecure),
userCodeAlg: userCodeAlg,
passwordHashAlg: crypto.NewBCrypt(sd.SecretGenerators.PasswordSaltCost),
}
}
func (s *Server) RegisterServer(grpcServer *grpc.Server) {
admin.RegisterAdminServiceServer(grpcServer, s)
}
func (s *Server) AppName() string {
return adminName
}
func (s *Server) MethodPrefix() string {
return admin.AdminService_MethodPrefix
}
func (s *Server) AuthMethods() authz.MethodMapping {
return admin.AdminService_AuthMethods
}
func (s *Server) RegisterGateway() server.GatewayFunc {
return admin.RegisterAdminServiceHandlerFromEndpoint
}
func (s *Server) GatewayPathPrefix() string {
return "/admin/v1"
}