mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:37:31 +00:00
fix: set correct owner on project grants (#9089)
# Which Problems Are Solved In versions previous to v2.66 it was possible to set a different resource owner on project grants. This was introduced with the new resource based API. The resource owner was possible to overwrite using the x-zitadel-org header. Because of this issue project grants got the wrong resource owner, instead of the owner of the project it got the granted org which is wrong because a resource owner of an aggregate is not allowed to change. # How the Problems Are Solved - The wrong owners of the events are set to the original owner of the project. - A new event is pushed to these aggregates `project.owner.corrected` - The projection updates the owners of the user grants if that event was written # Additional Changes The eventstore push function (replaced in version 2.66) writes the correct resource owner. # Additional Context closes https://github.com/zitadel/zitadel/issues/9072
This commit is contained in:
@@ -93,6 +93,10 @@ func (p *projectGrantProjection) Reducers() []handler.AggregateReducer {
|
||||
Event: project.ProjectRemovedType,
|
||||
Reduce: p.reduceProjectRemoved,
|
||||
},
|
||||
{
|
||||
Event: project.ProjectOwnerCorrected,
|
||||
Reduce: p.reduceOwnerCorrected,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -269,3 +273,17 @@ func (p *projectGrantProjection) reduceOwnerRemoved(event eventstore.Event) (*ha
|
||||
),
|
||||
), nil
|
||||
}
|
||||
|
||||
func (p *projectGrantProjection) reduceOwnerCorrected(event eventstore.Event) (*handler.Statement, error) {
|
||||
return handler.NewUpdateStatement(
|
||||
event,
|
||||
[]handler.Column{
|
||||
handler.NewCol(ProjectGrantColumnResourceOwner, event.Aggregate().ResourceOwner),
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectGrantColumnInstanceID, event.Aggregate().InstanceID),
|
||||
handler.NewCond(ProjectGrantColumnProjectID, event.Aggregate().ID),
|
||||
handler.NewUnequalCond(ProjectGrantColumnResourceOwner, event.Aggregate().ResourceOwner),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user