From bf6cb59b87e19bdb9a1bc4682711c6f9744370ce Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Tue, 1 Feb 2022 08:32:59 +0100 Subject: [PATCH] fix: list IDPs on Org (#3141) * fix: idp query * fix: remove failed events --- internal/api/grpc/management/idp_converter.go | 8 ++------ internal/query/failed_events.go | 4 +++- internal/query/idp.go | 11 ++++++++++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/internal/api/grpc/management/idp_converter.go b/internal/api/grpc/management/idp_converter.go index 7f3840fcea..86f5978f25 100644 --- a/internal/api/grpc/management/idp_converter.go +++ b/internal/api/grpc/management/idp_converter.go @@ -91,15 +91,11 @@ func listIDPsToModel(ctx context.Context, req *mgmt_pb.ListOrgIDPsRequest) (quer if err != nil { return nil, err } - iamQuery, err := query.NewIDPIDSearchQuery(domain.IAMID) + resourceOwnerQuery, err := query.NewIDPResourceOwnerListSearchQuery(domain.IAMID, authz.GetCtxData(ctx).OrgID) if err != nil { return nil, err } - resourceOwnerQuery, err := query.NewIDPResourceOwnerSearchQuery(authz.GetCtxData(ctx).OrgID) - if err != nil { - return nil, err - } - q = append(q, resourceOwnerQuery, iamQuery) + q = append(q, resourceOwnerQuery) return &query.IDPSearchQueries{ SearchRequest: query.SearchRequest{ Offset: offset, diff --git a/internal/query/failed_events.go b/internal/query/failed_events.go index 8c486fb08e..c78ec81f63 100644 --- a/internal/query/failed_events.go +++ b/internal/query/failed_events.go @@ -76,7 +76,9 @@ func (q *Queries) RemoveFailedEvent(ctx context.Context, projectionName string, Where(sq.Eq{ failedEventsColumnProjectionName: projectionName, failedEventsColumnFailedSequence: sequence, - }).ToSql() + }). + PlaceholderFormat(sq.Dollar). + ToSql() if err != nil { return errors.ThrowInternal(err, "QUERY-DGgh3", "Errors.RemoveFailed") } diff --git a/internal/query/idp.go b/internal/query/idp.go index 4fe23736c4..3831a06b3a 100644 --- a/internal/query/idp.go +++ b/internal/query/idp.go @@ -7,11 +7,12 @@ import ( "time" sq "github.com/Masterminds/squirrel" + "github.com/lib/pq" + "github.com/caos/zitadel/internal/crypto" "github.com/caos/zitadel/internal/domain" "github.com/caos/zitadel/internal/errors" "github.com/caos/zitadel/internal/query/projection" - "github.com/lib/pq" ) type IDP struct { @@ -239,6 +240,14 @@ func NewIDPResourceOwnerSearchQuery(value string) (SearchQuery, error) { return NewTextQuery(IDPResourceOwnerCol, value, TextEquals) } +func NewIDPResourceOwnerListSearchQuery(ids ...string) (SearchQuery, error) { + list := make([]interface{}, len(ids)) + for i, value := range ids { + list[i] = value + } + return NewListQuery(IDPResourceOwnerCol, list, ListIn) +} + func (q *IDPSearchQueries) toQuery(query sq.SelectBuilder) sq.SelectBuilder { query = q.SearchRequest.toQuery(query) for _, q := range q.Queries {