Ensure that restricted users can access repos for which they are members (#17460)

There is a small bug in the way that repo access is checked in
repoAssignment: Accessibility is checked by checking if the user has a
marked access to the repository instead of checking if the user has any
team granted access.

This PR changes this permissions check to use HasAccess() which does the
correct test. There is also a fix in the release api ListReleases where
it should return draft releases if the user is a member of a team with
write access to the releases.

The PR also adds a testcase.

Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
zeripath 2021-10-28 03:54:40 +01:00 committed by GitHub
parent 2b2eb5d0ad
commit 0b4a8be26b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 4 deletions

View file

@ -345,7 +345,7 @@ func repoAssignment(ctx *Context, repo *models.Repository) {
}
// Check access.
if ctx.Repo.Permission.AccessMode == models.AccessModeNone {
if !ctx.Repo.Permission.HasAccess() {
if ctx.FormString("go-get") == "1" {
EarlyResponseForGoGetMeta(ctx)
return