diff --git a/routers/web/repo/attachment.go b/routers/web/repo/attachment.go index 1cf50627a9c..c6d8828fac6 100644 --- a/routers/web/repo/attachment.go +++ b/routers/web/repo/attachment.go @@ -110,11 +110,6 @@ func GetAttachment(ctx *context.Context) { return } } else { // If we have the repository we check access - context.CheckRepoScopedToken(ctx, repository) - if ctx.Written() { - return - } - perm, err := access_model.GetUserRepoPermission(ctx, repository, ctx.Doer) if err != nil { ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err.Error()) diff --git a/tests/integration/attachment_test.go b/tests/integration/attachment_test.go index a92814ecee6..ff627264870 100644 --- a/tests/integration/attachment_test.go +++ b/tests/integration/attachment_test.go @@ -89,6 +89,9 @@ func TestCreateIssueAttachment(t *testing.T) { // Validate that attachment is available req = NewRequest(t, "GET", "/attachments/"+uuid) session.MakeRequest(t, req, http.StatusOK) + + // anonymous visit should be allowed because user2/repo1 is a public repository + MakeRequest(t, req, http.StatusOK) } func TestGetAttachment(t *testing.T) {