-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
404 Repo Inaccessible for Users in Team w/ All Repo Access #17003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We need logs. |
Relevant access.log entry: Entries from the gitea.log: |
Hmm odd, I was able to reliably perform this again to cause the problem. Just to confirm you created the repo first in the private org, created the team (with all repo access for read, code only), added the regular and restricted user to the team and were able to access the repo successfully? |
I didn't test the restricted user yet. But the regular one works. |
Okay, on Monday I'll test it with a regular user to see if that one works to confirm if it's specific to the restricted user or not. |
So I confirmed just now that with a regular (non-restricted) user I get the page you posted with "does not contain any content". So it appears to be something specific to a restricted user. |
Can confirm with 1.15.3 + restricted user added after a repo is added. Note that the repos are listed on the explore page even if they can't be accessed, but that's a different issue I guess, as I discovered that already on 1.14 branch: #16281 |
OK I've managed to make a testcase for this: PATCHdiff --git a/integrations/org_test.go b/integrations/org_test.go
index ee61aae6f..ac234de65 100644
--- a/integrations/org_test.go
+++ b/integrations/org_test.go
@@ -5,10 +5,12 @@
package integrations
import (
+ "fmt"
"net/http"
"strings"
"testing"
+ api "code.gitea.io/gitea/modules/structs"
"github.com/stretchr/testify/assert"
)
@@ -110,3 +112,64 @@ func TestPrivateOrg(t *testing.T) {
req = NewRequest(t, "GET", "/privated_org/private_repo_on_private_org")
session.MakeRequest(t, req, http.StatusOK)
}
+
+func TestOrgRestrictedUser(t *testing.T) {
+ defer prepareTestEnv(t)()
+
+ // privated_org is a private org who has id 23
+ orgName := "privated_org"
+
+ // public_repo_on_private_org is a public repo on privated_org
+ repoName := "public_repo_on_private_org"
+
+ // user29 is a restricted user who is not a member of the organization
+ restrictedUser := "user29"
+
+ // #17003 reports a bug whereby adding a restricted user to a read-only team doesn't work
+
+ // assert restrictedUser cannot see the org or the public repo
+ restrictedSession := loginUser(t, restrictedUser)
+ req := NewRequest(t, "GET", fmt.Sprintf("/%s", orgName))
+ restrictedSession.MakeRequest(t, req, http.StatusNotFound)
+
+ req = NewRequest(t, "GET", fmt.Sprintf("/%s/%s", orgName, repoName))
+ restrictedSession.MakeRequest(t, req, http.StatusNotFound)
+
+ // Therefore create a read-only team
+ adminSession := loginUser(t, "user1")
+ token := getTokenForLoggedInUser(t, adminSession)
+
+ teamToCreate := &api.CreateTeamOption{
+ Name: "codereader",
+ Description: "Code Reader",
+ IncludesAllRepositories: true,
+ Permission: "read",
+ Units: []string{"repo.code"},
+ }
+
+ req = NewRequestWithJSON(t, "POST",
+ fmt.Sprintf("/api/v1/orgs/%s/teams?token=%s", orgName, token), teamToCreate)
+
+ var apiTeam api.Team
+
+ resp := adminSession.MakeRequest(t, req, http.StatusCreated)
+ DecodeJSON(t, resp, &apiTeam)
+ checkTeamResponse(t, &apiTeam, teamToCreate.Name, teamToCreate.Description, teamToCreate.IncludesAllRepositories,
+ teamToCreate.Permission, teamToCreate.Units)
+ checkTeamBean(t, apiTeam.ID, teamToCreate.Name, teamToCreate.Description, teamToCreate.IncludesAllRepositories,
+ teamToCreate.Permission, teamToCreate.Units)
+ //teamID := apiTeam.ID
+
+ // Now we need to add the restricted user to the team
+ req = NewRequest(t, "PUT",
+ fmt.Sprintf("/api/v1/teams/%d/members/%s?token=%s", apiTeam.ID, restrictedUser, token))
+ _ = adminSession.MakeRequest(t, req, http.StatusNoContent)
+
+ // Now we need to check if the restrictedUser can access the repo
+ req = NewRequest(t, "GET", fmt.Sprintf("/%s", orgName))
+ restrictedSession.MakeRequest(t, req, http.StatusOK)
+
+ req = NewRequest(t, "GET", fmt.Sprintf("/%s/%s", orgName, repoName))
+ restrictedSession.MakeRequest(t, req, http.StatusOK)
+
+}
diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml
index 6860d00b3..dc8ebecfc 100644
--- a/models/fixtures/repository.yml
+++ b/models/fixtures/repository.yml
@@ -568,7 +568,7 @@
-
id: 40
owner_id: 23
- owner_name: limited_org
+ owner_name: privated_org
lower_name: public_repo_on_private_org
name: public_repo_on_private_org
is_private: false
@@ -581,7 +581,7 @@
-
id: 41
owner_id: 23
- owner_name: limited_org
+ owner_name: privated_org
lower_name: private_repo_on_private_org
name: private_repo_on_private_org
is_private: true |
Sorry it's taken me so long to look at this. I think the related PR should solve this issue. |
Running using your pre-built Win x64 binary. This is being started/stopped using a Windows service created per your installation instructions running as a local user with 'full control' of relevant folders.
[x]
):Description
Note that creating the team and THEN creating the repo works fine, just not in reverse. The retroactively applied permissions for a team created after the repo was created is botched.
The text was updated successfully, but these errors were encountered: