zitadel/pkg/management/api/grpc/server.go
Michael Waeger b9c938594c
feat: Policy (#79)
* policy added

* Make it executable

* Make it executable, corrections

* password age policy added

* password lockout policy added

* corrections

* policy added

* Make it executable

* Make it executable, corrections

* password age policy added

* password lockout policy added

* corrections

* fix(repository): remove second policy

* complaints corrected

* Init tests

* add some tests

* more tests added

* systemfefaults added

* default values load added

* check for default value added

* fixes

* fixed

* create policy if not exists

* eventstore tests added

Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
2020-05-14 11:48:57 +02:00

58 lines
1.5 KiB
Go

package grpc
import (
"github.com/caos/zitadel/internal/api/auth"
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/api/grpc/server/middleware"
mgmt_auth "github.com/caos/zitadel/internal/management/auth"
"github.com/caos/zitadel/internal/management/repository"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"google.golang.org/grpc"
)
var _ ManagementServiceServer = (*Server)(nil)
type Server struct {
port string
project repository.ProjectRepository
policy repository.PolicyRepository
org repository.OrgRepository
orgMember repository.OrgMemberRepository
user repository.UserRepository
usergrant repository.UserGrantRepository
verifier *mgmt_auth.TokenVerifier
authZ auth.Config
}
func StartServer(conf grpc_util.ServerConfig, authZ auth.Config, repo repository.Repository) *Server {
return &Server{
port: conf.Port,
project: repo,
policy: repo,
org: repo,
orgMember: repo,
user: repo,
usergrant: repo,
authZ: authZ,
verifier: mgmt_auth.Start(),
}
}
func (s *Server) GRPCPort() string {
return s.port
}
func (s *Server) GRPCServer() (*grpc.Server, error) {
gs := grpc.NewServer(
middleware.TracingStatsServer("/Healthz", "/Ready", "/Validate"),
grpc.UnaryInterceptor(
grpc_middleware.ChainUnaryServer(
middleware.ErrorHandler(),
ManagementService_Authorization_Interceptor(s.verifier, &s.authZ),
),
),
)
RegisterManagementServiceServer(gs, s)
return gs, nil
}