mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 04:37:31 +00:00
fix: import of trigger actions and export of idp links (#4576)
Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
@@ -84,13 +84,20 @@ func (s *Server) ExportData(ctx context.Context, req *admin_pb.ExportDataRequest
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
orgIDPs := make([]string, 0)
|
||||
for _, idp := range org.OidcIdps {
|
||||
orgIDPs = append(orgIDPs, idp.GetIdpId())
|
||||
}
|
||||
for _, idp := range org.JwtIdps {
|
||||
orgIDPs = append(orgIDPs, idp.GetIdpId())
|
||||
}
|
||||
|
||||
org.LabelPolicy, err = s.getLabelPolicy(ctx, org.GetOrgId())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
org.LoginPolicy, err = s.getLoginPolicy(ctx, org.GetOrgId())
|
||||
org.LoginPolicy, err = s.getLoginPolicy(ctx, org.GetOrgId(), orgIDPs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -368,7 +375,7 @@ func (s *Server) getLabelPolicy(ctx context.Context, orgID string) (_ *managemen
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Server) getLoginPolicy(ctx context.Context, orgID string) (_ *management_pb.AddCustomLoginPolicyRequest, err error) {
|
||||
func (s *Server) getLoginPolicy(ctx context.Context, orgID string, orgIDPs []string) (_ *management_pb.AddCustomLoginPolicyRequest, err error) {
|
||||
ctx, span := tracing.NewSpan(ctx)
|
||||
defer func() { span.EndWithError(err) }()
|
||||
|
||||
@@ -399,9 +406,22 @@ func (s *Server) getLoginPolicy(ctx context.Context, orgID string) (_ *managemen
|
||||
}
|
||||
idpLinks := make([]*management_pb.AddCustomLoginPolicyRequest_IDP, 0)
|
||||
for _, idpLink := range idpLinksQuery.Links {
|
||||
found := false
|
||||
for _, orgIDP := range orgIDPs {
|
||||
if orgIDP == idpLink.IDPID {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
ownerType := idp_pb.IDPOwnerType_IDP_OWNER_TYPE_UNSPECIFIED
|
||||
if found {
|
||||
ownerType = idp_pb.IDPOwnerType_IDP_OWNER_TYPE_ORG
|
||||
} else {
|
||||
ownerType = idp_pb.IDPOwnerType_IDP_OWNER_TYPE_SYSTEM
|
||||
}
|
||||
idpLinks = append(idpLinks, &management_pb.AddCustomLoginPolicyRequest_IDP{
|
||||
IdpId: idpLink.IDPID,
|
||||
OwnerType: idp_pb.IDPOwnerType(idpLink.IDPType),
|
||||
OwnerType: ownerType,
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -871,6 +871,15 @@ func (s *Server) dataOrgsV1ToDataOrgs(ctx context.Context, dataOrgs *v1_pb.Impor
|
||||
|
||||
orgs := make([]*admin_pb.DataOrg, 0)
|
||||
for _, orgV1 := range dataOrgs.Orgs {
|
||||
triggerActions := make([]*management_pb.SetTriggerActionsRequest, 0)
|
||||
for _, action := range orgV1.GetTriggerActions() {
|
||||
triggerActions = append(triggerActions, &management_pb.SetTriggerActionsRequest{
|
||||
FlowType: strconv.Itoa(int(action.GetFlowType().Number())),
|
||||
TriggerType: strconv.Itoa(int(action.GetTriggerType().Number())),
|
||||
ActionIds: action.ActionIds,
|
||||
})
|
||||
}
|
||||
|
||||
org := &admin_pb.DataOrg{
|
||||
OrgId: orgV1.GetOrgId(),
|
||||
Org: orgV1.GetOrg(),
|
||||
@@ -886,7 +895,7 @@ func (s *Server) dataOrgsV1ToDataOrgs(ctx context.Context, dataOrgs *v1_pb.Impor
|
||||
OidcApps: orgV1.GetOidcApps(),
|
||||
HumanUsers: orgV1.GetHumanUsers(),
|
||||
MachineUsers: orgV1.GetMachineUsers(),
|
||||
TriggerActions: orgV1.GetTriggerActions(),
|
||||
TriggerActions: triggerActions,
|
||||
Actions: orgV1.GetActions(),
|
||||
ProjectGrants: orgV1.GetProjectGrants(),
|
||||
UserGrants: orgV1.GetUserGrants(),
|
||||
|
Reference in New Issue
Block a user