.git URL for a project responds differently if a private project exists
This project exists. When I hit its URL with .git
suffix (unauthenticated), it redirects to the project's show path.
$ curl -si https://gitlab.com/issue-reproduce/private-subgroup/reduce-permissions-per-project.git | grep location
location: https://gitlab.com/issue-reproduce/private-subgroup/reduce-permissions-per-project
$ curl -si https://gitlab.com/issue-reproduce/private-subgroup/reduce-permissions-per-project | grep location
location: https://gitlab.com/users/sign_in
This project doesn't exist. When I hit its URL with .git
suffix (unauthenticated), it redirects to the sign-in page.
$ curl -si https://gitlab.com/issue-reproduce/private-subgroup/reduce-permissions-per-project2.git | grep location
location: https://gitlab.com/users/sign_in
$ curl -si https://gitlab.com/issue-reproduce/private-subgroup/reduce-permissions-per-project2 | grep location
location: https://gitlab.com/users/sign_in
This appears to be because the ProjectUrlConstrainer
used in our routing checks whether or not the project exists. If it doesn't, we won't even visit the ProjectsController
.
In Projects::ApplicationController#project
, we use RoutableActions#find_routable!
which does the 'not found' (redirect to sign-in) response if the project doesn't exist.
However, ProjectsController#redirect_git_extension
doesn't call #project
, and happens before project
is called: https://gitlab.com/gitlab-org/gitlab/-/blob/76f0ff981cb6a609dc63e1ad80036294ed805c3a/app/controllers/projects_controller.rb#L19-20