req = NewRequest(t, "GET", "/privated_org/private_repo_on_private_org")
session.MakeRequest(t, req, http.StatusNotFound)
+ // non-org member who is collaborator on repo in private org
+ session = loginUser(t, "user4")
+ req = NewRequest(t, "GET", "/privated_org")
+ session.MakeRequest(t, req, http.StatusNotFound)
+ req = NewRequest(t, "GET", "/privated_org/public_repo_on_private_org") // colab of this repo
+ session.MakeRequest(t, req, http.StatusOK)
+ req = NewRequest(t, "GET", "/privated_org/private_repo_on_private_org")
+ session.MakeRequest(t, req, http.StatusNotFound)
+
// site admin
session = loginUser(t, "user1")
req = NewRequest(t, "GET", "/privated_org")
repo.mustOwner(e)
}
- if repo.Owner.IsOrganization() && !HasOrgVisible(repo.Owner, user) {
+ var isCollaborator bool
+ if user != nil {
+ isCollaborator, err = repo.isCollaborator(e, user.ID)
+ if err != nil {
+ return perm, err
+ }
+ }
+
+ // Prevent strangers from checking out public repo of private orginization
+ // Allow user if they are collaborator of a repo within a private orginization but not a member of the orginization itself
+ if repo.Owner.IsOrganization() && !HasOrgVisible(repo.Owner, user) && !isCollaborator {
perm.AccessMode = AccessModeNone
return
}
perm.UnitsMode = make(map[UnitType]AccessMode)
// Collaborators on organization
- if isCollaborator, err := repo.isCollaborator(e, user.ID); err != nil {
- return perm, err
- } else if isCollaborator {
+ if isCollaborator {
for _, u := range repo.Units {
perm.UnitsMode[u.Type] = perm.AccessMode
}