mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-18 16:35:27 +02:00
refactor: update groupAssignment func
ensure that groups that have private parents remain inaccessible
This commit is contained in:
parent
d9c8a28a5f
commit
496140d537
@ -120,6 +120,11 @@ func groupAssignment(ctx commonCtx, doer *user_model.User, isSigned bool, handle
|
|||||||
handleOtherError("error checking group access", err)
|
handleOtherError("error checking group access", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
privateBecauseOfParent, err := group.IsPrivateBecauseOfParentPermissions(ctx, doer)
|
||||||
|
if err != nil {
|
||||||
|
handleOtherError("error checking group access", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
if group.Owner == nil {
|
if group.Owner == nil {
|
||||||
err = group.LoadOwner(ctx)
|
err = group.LoadOwner(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -255,6 +260,9 @@ func groupAssignment(ctx commonCtx, doer *user_model.User, isSigned bool, handle
|
|||||||
}
|
}
|
||||||
repoGroup.IsGroupAdmin = repoGroup.IsGroupAdmin || isAdmin
|
repoGroup.IsGroupAdmin = repoGroup.IsGroupAdmin || isAdmin
|
||||||
}
|
}
|
||||||
|
if !repoGroup.IsOwner && !repoGroup.IsGroupAdmin {
|
||||||
|
canAccess = canAccess && !privateBecauseOfParent
|
||||||
|
}
|
||||||
assign(repoGroup, canAccess)
|
assign(repoGroup, canAccess)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +304,7 @@ func GroupAssignmentWeb(args GroupAssignmentOptions) func(ctx *Context) {
|
|||||||
is, _ := organization.IsPublicMembership(ctx, ctx.Org.Organization.ID, uid)
|
is, _ := organization.IsPublicMembership(ctx, ctx.Org.Organization.ID, uid)
|
||||||
return is
|
return is
|
||||||
}
|
}
|
||||||
ctx.Data["CanReadProjects"] = repoGroup.CanReadUnit(ctx, unit.TypeProjects)
|
ctx.Data["CanReadProjects"] = repoGroup.CanReadUnit(ctx, ctx.Doer, unit.TypeProjects)
|
||||||
ctx.Data["CanCreateOrgRepo"] = repoGroup.CanCreateRepoOrGroup
|
ctx.Data["CanCreateOrgRepo"] = repoGroup.CanCreateRepoOrGroup
|
||||||
|
|
||||||
ctx.Data["IsGroupAdmin"] = repoGroup.IsGroupAdmin
|
ctx.Data["IsGroupAdmin"] = repoGroup.IsGroupAdmin
|
||||||
@ -356,10 +364,14 @@ func GroupAssignmentAPI() func(ctx *APIContext) {
|
|||||||
ctx.APIErrorNotFound(nil)
|
ctx.APIErrorNotFound(nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if ctx.IsSigned {
|
||||||
if !canAccess && group.Visibility != structs.VisibleTypePublic {
|
if !canAccess && group.Visibility != structs.VisibleTypePublic {
|
||||||
|
ctx.APIErrorNotFound(nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !canAccess {
|
||||||
ctx.APIErrorNotFound(nil)
|
ctx.APIErrorNotFound(nil)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
ctx.RepoGroup = repoGroup
|
ctx.RepoGroup = repoGroup
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user