Commit 90328145 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'dblessing-fix-public-project-ssh-only-ci-failure' into 'master'

Allow CI to clone public projects when HTTP protocol is disabled

Closes #65805

See merge request gitlab-org/gitlab-ce!31632
parents 8c8824d4 7f00bcb9
......@@ -49,7 +49,8 @@ class Projects::GitHttpClientController < Projects::ApplicationController
send_final_spnego_response
return # Allow access
end
elsif project && download_request? && Guest.can?(:download_code, project)
elsif project && download_request? && http_allowed? && Guest.can?(:download_code, project)
@authentication_result = Gitlab::Auth::Result.new(nil, project, :none, [:download_code])
return # Allow access
......@@ -113,4 +114,8 @@ class Projects::GitHttpClientController < Projects::ApplicationController
def ci?
authentication_result.ci?(project)
end
def http_allowed?
Gitlab::ProtocolAccess.allowed?('http')
end
end
---
title: Allow CI to clone public projects when HTTP protocol is disabled
merge_request: 31632
author:
type: fixed
......@@ -12,4 +12,15 @@ describe Projects::GitHttpController do
expect(response.status).to eq(403)
end
end
describe 'GET #info_refs' do
it 'returns 401 for unauthenticated requests to public repositories when http protocol is disabled' do
stub_application_setting(enabled_git_access_protocol: 'ssh')
project = create(:project, :public, :repository)
get :info_refs, params: { service: 'git-upload-pack', namespace_id: project.namespace.to_param, project_id: project.path + '.git' }
expect(response.status).to eq(401)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment