2022-02-16 15:49:17 +00:00
|
|
|
package admin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/api/grpc/object"
|
|
|
|
admin_pb "github.com/zitadel/zitadel/pkg/grpc/admin"
|
2022-02-16 15:49:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (s *Server) ListSecretGenerators(ctx context.Context, req *admin_pb.ListSecretGeneratorsRequest) (*admin_pb.ListSecretGeneratorsResponse, error) {
|
|
|
|
queries, err := listSecretGeneratorToModel(req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
result, err := s.query.SearchSecretGenerators(ctx, queries)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &admin_pb.ListSecretGeneratorsResponse{
|
2023-07-07 14:46:02 +00:00
|
|
|
Result: SecretGeneratorsToPb(result.SecretGenerators),
|
2023-10-19 10:19:10 +00:00
|
|
|
Details: object.ToListDetails(result.Count, result.Sequence, result.LastRun),
|
2022-02-16 15:49:17 +00:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) GetSecretGenerator(ctx context.Context, req *admin_pb.GetSecretGeneratorRequest) (*admin_pb.GetSecretGeneratorResponse, error) {
|
|
|
|
generator, err := s.query.SecretGeneratorByType(ctx, SecretGeneratorTypeToDomain(req.GeneratorType))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &admin_pb.GetSecretGeneratorResponse{
|
|
|
|
SecretGenerator: SecretGeneratorToPb(generator),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) UpdateSecretGenerator(ctx context.Context, req *admin_pb.UpdateSecretGeneratorRequest) (*admin_pb.UpdateSecretGeneratorResponse, error) {
|
|
|
|
details, err := s.command.ChangeSecretGeneratorConfig(ctx, SecretGeneratorTypeToDomain(req.GeneratorType), UpdateSecretGeneratorToConfig(req))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &admin_pb.UpdateSecretGeneratorResponse{
|
|
|
|
Details: object.ChangeToDetailsPb(
|
|
|
|
details.Sequence,
|
|
|
|
details.EventDate,
|
|
|
|
details.ResourceOwner),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2022-12-14 06:17:36 +00:00
|
|
|
func (s *Server) GetSecurityPolicy(ctx context.Context, req *admin_pb.GetSecurityPolicyRequest) (*admin_pb.GetSecurityPolicyResponse, error) {
|
|
|
|
policy, err := s.query.SecurityPolicy(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &admin_pb.GetSecurityPolicyResponse{
|
|
|
|
Policy: SecurityPolicyToPb(policy),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) SetSecurityPolicy(ctx context.Context, req *admin_pb.SetSecurityPolicyRequest) (*admin_pb.SetSecurityPolicyResponse, error) {
|
2024-02-28 10:21:11 +00:00
|
|
|
details, err := s.command.SetSecurityPolicy(ctx, securityPolicyToCommand(req))
|
2022-12-14 06:17:36 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &admin_pb.SetSecurityPolicyResponse{
|
|
|
|
Details: object.DomainToChangeDetailsPb(details),
|
|
|
|
}, nil
|
|
|
|
}
|