From 5640a0ef33bb6a243f87d8cb927b91b43af09ead Mon Sep 17 00:00:00 2001 From: Silvan Date: Mon, 3 Jan 2022 11:50:38 +0100 Subject: [PATCH] refactor: remove unused code (#2798) * refactor(domain): add user type * fix(projections): start with login names * fix(login_policy): correct handling of user domain claimed event * fix(projections): add members * refactor: simplify member projections * add migration for members * add metadata to member projections * refactor: login name projection * fix: set correct suffixes on login name projections * test(projections): login name reduces * fix: correct cols in reduce member * test(projections): org, iam, project members * member additional cols and conds as opt, add project grant members * fix(migration): members * fix(migration): correct database name * migration version * migs * better naming for member cond and col * split project and project grant members * prepare member columns * feat(queries): membership query * test(queries): membership prepare * fix(queries): multiple projections for latest sequence * fix(api): use query for membership queries in auth and management * feat: org member queries * fix(api): use query for iam member calls * fix(queries): org members * fix(queries): project members * fix(queries): project grant members * refactor: remove unsued methods in repo-interfaces * refactor(eventstore): rename EventPusher to Command, EventReader to Event, PushEvents to Push and FilterEvents to Filter --- internal/api/grpc/management/idp.go | 4 +-- internal/management/repository/org.go | 5 ---- internal/management/repository/project.go | 5 ---- internal/query/projection/org_member.go | 13 +++------- .../query/projection/project_grant_member.go | 26 ++++++------------- internal/query/projection/project_member.go | 13 +++------- 6 files changed, 18 insertions(+), 48 deletions(-) diff --git a/internal/api/grpc/management/idp.go b/internal/api/grpc/management/idp.go index 5780d19438..7d49dca2c2 100644 --- a/internal/api/grpc/management/idp.go +++ b/internal/api/grpc/management/idp.go @@ -79,7 +79,7 @@ func (s *Server) ReactivateOrgIDP(ctx context.Context, req *mgmt_pb.ReactivateOr } func (s *Server) RemoveOrgIDP(ctx context.Context, req *mgmt_pb.RemoveOrgIDPRequest) (*mgmt_pb.RemoveOrgIDPResponse, error) { - idpProviders, err := s.org.GetIDPProvidersByIDPConfigID(ctx, authz.GetCtxData(ctx).OrgID, req.IdpId) + idp, err := s.query.IDPByIDAndResourceOwner(ctx, req.IdpId, authz.GetCtxData(ctx).OrgID) if err != nil { return nil, err } @@ -87,7 +87,7 @@ func (s *Server) RemoveOrgIDP(ctx context.Context, req *mgmt_pb.RemoveOrgIDPRequ if err != nil { return nil, err } - _, err = s.command.RemoveIDPConfig(ctx, req.IdpId, authz.GetCtxData(ctx).OrgID, len(idpProviders) > 0, externalIDPViewsToDomain(externalIDPs)...) + _, err = s.command.RemoveIDPConfig(ctx, req.IdpId, authz.GetCtxData(ctx).OrgID, idp != nil, externalIDPViewsToDomain(externalIDPs)...) if err != nil { return nil, err } diff --git a/internal/management/repository/org.go b/internal/management/repository/org.go index 41e18b898a..12e06ff65f 100644 --- a/internal/management/repository/org.go +++ b/internal/management/repository/org.go @@ -15,13 +15,8 @@ type OrgRepository interface { Languages(ctx context.Context) ([]language.Tag, error) OrgChanges(ctx context.Context, id string, lastSequence uint64, limit uint64, sortAscending bool, auditLogRetention time.Duration) (*org_model.OrgChanges, error) - SearchMyOrgMembers(ctx context.Context, request *org_model.OrgMemberSearchRequest) (*org_model.OrgMemberSearchResponse, error) - GetOrgMemberRoles() []string - SearchIDPConfigs(ctx context.Context, request *iam_model.IDPConfigSearchRequest) (*iam_model.IDPConfigSearchResponse, error) - IDPConfigByID(ctx context.Context, id string) (*iam_model.IDPConfigView, error) - SearchIDPProviders(ctx context.Context, request *iam_model.IDPProviderSearchRequest) (*iam_model.IDPProviderSearchResponse, error) GetIDPProvidersByIDPConfigID(ctx context.Context, aggregateID, idpConfigID string) ([]*iam_model.IDPProviderView, error) } diff --git a/internal/management/repository/project.go b/internal/management/repository/project.go index 3cdb739e49..bddb282c69 100644 --- a/internal/management/repository/project.go +++ b/internal/management/repository/project.go @@ -10,17 +10,12 @@ import ( ) type ProjectRepository interface { - ProjectMemberByID(ctx context.Context, projectID, userID string) (*model.ProjectMemberView, error) - SearchProjectMembers(ctx context.Context, request *model.ProjectMemberSearchRequest) (*model.ProjectMemberSearchResponse, error) GetProjectMemberRoles(ctx context.Context) ([]string, error) ProjectChanges(ctx context.Context, id string, lastSequence uint64, limit uint64, sortAscending bool, retention time.Duration) (*model.ProjectChanges, error) ApplicationChanges(ctx context.Context, projectID string, appID string, lastSequence uint64, limit uint64, sortAscending bool, retention time.Duration) (*model.ApplicationChanges, error) - SearchProjectGrantMembers(ctx context.Context, request *model.ProjectGrantMemberSearchRequest) (*model.ProjectGrantMemberSearchResponse, error) - - ProjectGrantMemberByID(ctx context.Context, projectID, userID string) (*model.ProjectGrantMemberView, error) GetProjectGrantMemberRoles() []string GetIAMByID(ctx context.Context) (*iam_model.IAM, error) diff --git a/internal/query/projection/org_member.go b/internal/query/projection/org_member.go index a79e8e20cf..a3d0871cf0 100644 --- a/internal/query/projection/org_member.go +++ b/internal/query/projection/org_member.go @@ -50,6 +50,10 @@ func (p *OrgMemberProjection) reducers() []handler.AggregateReducer { Event: org.MemberRemovedEventType, Reduce: p.reduceRemoved, }, + { + Event: org.OrgRemovedEventType, + Reduce: p.reduceOrgRemoved, + }, }, }, { @@ -61,15 +65,6 @@ func (p *OrgMemberProjection) reducers() []handler.AggregateReducer { }, }, }, - { - Aggregate: org.AggregateType, - EventRedusers: []handler.EventReducer{ - { - Event: org.OrgRemovedEventType, - Reduce: p.reduceOrgRemoved, - }, - }, - }, } } diff --git a/internal/query/projection/project_grant_member.go b/internal/query/projection/project_grant_member.go index 684bacb4b0..7860e775bd 100644 --- a/internal/query/projection/project_grant_member.go +++ b/internal/query/projection/project_grant_member.go @@ -52,6 +52,14 @@ func (p *ProjectGrantMemberProjection) reducers() []handler.AggregateReducer { Event: project.GrantMemberRemovedType, Reduce: p.reduceRemoved, }, + { + Event: project.ProjectRemovedType, + Reduce: p.reduceProjectRemoved, + }, + { + Event: project.GrantRemovedType, + Reduce: p.reduceProjectGrantRemoved, + }, }, }, { @@ -72,24 +80,6 @@ func (p *ProjectGrantMemberProjection) reducers() []handler.AggregateReducer { }, }, }, - { - Aggregate: project.AggregateType, - EventRedusers: []handler.EventReducer{ - { - Event: project.ProjectRemovedType, - Reduce: p.reduceProjectRemoved, - }, - }, - }, - { - Aggregate: project.AggregateType, - EventRedusers: []handler.EventReducer{ - { - Event: project.GrantRemovedType, - Reduce: p.reduceProjectGrantRemoved, - }, - }, - }, } } diff --git a/internal/query/projection/project_member.go b/internal/query/projection/project_member.go index 10b8379f9a..d338e6195f 100644 --- a/internal/query/projection/project_member.go +++ b/internal/query/projection/project_member.go @@ -52,6 +52,10 @@ func (p *ProjectMemberProjection) reducers() []handler.AggregateReducer { Event: project.MemberRemovedType, Reduce: p.reduceRemoved, }, + { + Event: project.ProjectRemovedType, + Reduce: p.reduceProjectRemoved, + }, }, }, { @@ -72,15 +76,6 @@ func (p *ProjectMemberProjection) reducers() []handler.AggregateReducer { }, }, }, - { - Aggregate: project.AggregateType, - EventRedusers: []handler.EventReducer{ - { - Event: project.ProjectRemovedType, - Reduce: p.reduceProjectRemoved, - }, - }, - }, } }