As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Unverified Commit 30171090 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

GitLab /api/allowed endpoint requires POST request


This commit made changes to GitLab shell to work with huge pushed (ex.
1k branhes) using POST request to API

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 76f7f349
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -21,7 +21,7 @@ class GitlabAccess
else
# reset GL_ID env since we stop git push here
ENV['GL_ID'] = nil
puts "GitLab: You are not allowed to access #{@ref_name}!"
puts "GitLab: You are not allowed to access some of the refs!"
exit 1
end
end
Loading
Loading
Loading
Loading
@@ -23,8 +23,8 @@ class GitlabNet
params.merge!(user_id: actor.gsub("user-", ""))
end
url = "#{host}/allowed?" + URI.encode_www_form(params)
resp = get(url)
url = "#{host}/allowed"
resp = post(url, params)
!!(resp.code == '200' && resp.body == 'true')
end
Loading
Loading
@@ -59,10 +59,15 @@ class GitlabNet
end
end
def http_request_for(url)
def http_request_for(url, method = :get)
user = config.http_settings['user']
password = config.http_settings['password']
Net::HTTP::Get.new(url.request_uri).tap { |r| r.basic_auth(user, password) if user && password }
if method == :get
Net::HTTP::Get.new(url.request_uri).tap { |r| r.basic_auth(user, password) if user && password }
else
Net::HTTP::Post.new(url.request_uri).tap { |r| r.basic_auth(user, password) if user && password }
end
end
def get(url)
Loading
Loading
@@ -81,6 +86,23 @@ class GitlabNet
end
end
def post(url, params)
$logger.debug "Performing POST #{url}"
url = URI.parse(url)
http = http_client_for(url)
request = http_request_for(url, :post)
request.set_form_data(params)
http.start { |http| http.request(request) }.tap do |resp|
if resp.code == "200"
$logger.debug { "Received response #{resp.code} => <#{resp.body}>." }
else
$logger.error { "API call <POST #{url}> failed: #{resp.code} => <#{resp.body}>." }
end
end
end
def cert_store
@cert_store ||= OpenSSL::X509::Store.new.tap do |store|
store.set_default_paths
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment