mirror of
https://github.com/zitadel/zitadel.git
synced 2025-04-25 07:04:43 +00:00

* add setup steps * refactoring * omitempty * cleanup * begin org * create org * setup org * setup org * merge * fixes * fixes * fixes * add project * add oidc application * fix app creation * add resourceOwner to writemodels * resource owner * cleanup * global org, iam project and iam member in setup * logs * logs * logs * cleanup * Update internal/v2/command/project.go Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com> * check project state * add org domain commands * add org status changes and member commands * fixes * policies * login policy * fix iam project event * mapper * label policy * change to command * fix * fix * handle change event differently and lot of fixes * fixes * changedEvent handling Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com>
111 lines
4.0 KiB
Go
111 lines
4.0 KiB
Go
package management
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/golang/protobuf/ptypes/empty"
|
|
|
|
"github.com/caos/zitadel/internal/api/authz"
|
|
"github.com/caos/zitadel/pkg/grpc/management"
|
|
)
|
|
|
|
func (s *Server) GetLoginPolicy(ctx context.Context, _ *empty.Empty) (*management.LoginPolicyView, error) {
|
|
result, err := s.org.GetLoginPolicy(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return loginPolicyViewFromModel(result), nil
|
|
}
|
|
|
|
func (s *Server) GetDefaultLoginPolicy(ctx context.Context, _ *empty.Empty) (*management.LoginPolicyView, error) {
|
|
result, err := s.org.GetDefaultLoginPolicy(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return loginPolicyViewFromModel(result), nil
|
|
}
|
|
|
|
func (s *Server) CreateLoginPolicy(ctx context.Context, policy *management.LoginPolicyRequest) (*management.LoginPolicy, error) {
|
|
result, err := s.command.AddLoginPolicy(ctx, loginPolicyRequestToDomain(ctx, policy))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return loginPolicyFromDomain(result), nil
|
|
}
|
|
|
|
func (s *Server) UpdateLoginPolicy(ctx context.Context, policy *management.LoginPolicyRequest) (*management.LoginPolicy, error) {
|
|
result, err := s.command.ChangeLoginPolicy(ctx, loginPolicyRequestToDomain(ctx, policy))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return loginPolicyFromDomain(result), nil
|
|
}
|
|
|
|
func (s *Server) RemoveLoginPolicy(ctx context.Context, _ *empty.Empty) (*empty.Empty, error) {
|
|
err := s.command.RemoveLoginPolicy(ctx, authz.GetCtxData(ctx).OrgID)
|
|
return &empty.Empty{}, err
|
|
}
|
|
|
|
func (s *Server) GetLoginPolicyIdpProviders(ctx context.Context, request *management.IdpProviderSearchRequest) (*management.IdpProviderSearchResponse, error) {
|
|
result, err := s.org.SearchIDPProviders(ctx, idpProviderSearchRequestToModel(request))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return idpProviderSearchResponseFromModel(result), nil
|
|
}
|
|
|
|
func (s *Server) AddIdpProviderToLoginPolicy(ctx context.Context, provider *management.IdpProviderAdd) (*management.IdpProvider, error) {
|
|
result, err := s.command.AddIDPProviderToLoginPolicy(ctx, idpProviderAddToDomain(ctx, provider))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return idpProviderFromDomain(result), nil
|
|
}
|
|
|
|
func (s *Server) RemoveIdpProviderFromLoginPolicy(ctx context.Context, provider *management.IdpProviderID) (*empty.Empty, error) {
|
|
err := s.command.RemoveIDPProviderFromLoginPolicy(ctx, idpProviderIDToDomain(ctx, provider))
|
|
return &empty.Empty{}, err
|
|
}
|
|
|
|
func (s *Server) GetLoginPolicySecondFactors(ctx context.Context, _ *empty.Empty) (*management.SecondFactorsResult, error) {
|
|
result, err := s.org.SearchSecondFactors(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return secondFactorResultFromModel(result), nil
|
|
}
|
|
|
|
func (s *Server) AddSecondFactorToLoginPolicy(ctx context.Context, mfa *management.SecondFactor) (*management.SecondFactor, error) {
|
|
result, err := s.command.AddSecondFactorToLoginPolicy(ctx, secondFactorTypeToDomain(mfa), authz.GetCtxData(ctx).OrgID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return secondFactorFromDomain(result), nil
|
|
}
|
|
|
|
func (s *Server) RemoveSecondFactorFromLoginPolicy(ctx context.Context, mfa *management.SecondFactor) (*empty.Empty, error) {
|
|
err := s.command.RemoveSecondFactorFromLoginPolicy(ctx, secondFactorTypeToDomain(mfa), authz.GetCtxData(ctx).OrgID)
|
|
return &empty.Empty{}, err
|
|
}
|
|
|
|
func (s *Server) GetLoginPolicyMultiFactors(ctx context.Context, _ *empty.Empty) (*management.MultiFactorsResult, error) {
|
|
result, err := s.org.SearchMultiFactors(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return multiFactorResultFromModel(result), nil
|
|
}
|
|
|
|
func (s *Server) AddMultiFactorToLoginPolicy(ctx context.Context, mfa *management.MultiFactor) (*management.MultiFactor, error) {
|
|
result, err := s.command.AddMultiFactorToLoginPolicy(ctx, multiFactorTypeToDomain(mfa), authz.GetCtxData(ctx).OrgID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return multiFactorFromDomain(result), nil
|
|
}
|
|
|
|
func (s *Server) RemoveMultiFactorFromLoginPolicy(ctx context.Context, mfa *management.MultiFactor) (*empty.Empty, error) {
|
|
err := s.command.RemoveMultiFactorFromLoginPolicy(ctx, multiFactorTypeToDomain(mfa), authz.GetCtxData(ctx).OrgID)
|
|
return &empty.Empty{}, err
|
|
}
|