Skip to content

Allow CI to clone public projects when HTTP protocol is disabled

What does this MR do?

The problem is that Git always sends an unauthenticated request before sending a request with auth. For a public project, the last conditional case at https://gitlab.com/gitlab-org/gitlab-ce/blob/fe214a217ca95c2c4a53c501f372367fecaf7f99/app/controllers/projects/git_http_client_controller.rb#L52 was passing with the first unauthenticated request, since it is public and guest/unauthenticated users can clone public projects. But then as the request passes further down eventually we check if HTTP is allowed and see that it isn't. Since it's not authenticated as a CI request specifically, we say it's not allowed and it fails.

This fix works because it says even if the project is public, if HTTP is not allowed, let that first unauthenticated request fail through. Then git actually sends the CI token and the next request is authenticated correctly as CI and it's allowed to clone via HTTP.

Does this MR meet the acceptance criteria?

Conformity

Performance and testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Closes #65805 (closed)

Edited by Tomasz Maczukin

Merge request reports