diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /lib/gitlab/external_authorization | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'lib/gitlab/external_authorization')
-rw-r--r-- | lib/gitlab/external_authorization/client.rb | 11 | ||||
-rw-r--r-- | lib/gitlab/external_authorization/response.rb | 10 |
2 files changed, 13 insertions, 8 deletions
diff --git a/lib/gitlab/external_authorization/client.rb b/lib/gitlab/external_authorization/client.rb index 7985e6dcf7b..fc859304eab 100644 --- a/lib/gitlab/external_authorization/client.rb +++ b/lib/gitlab/external_authorization/client.rb @@ -17,23 +17,28 @@ module Gitlab end def request_access - response = Excon.post( + response = Gitlab::HTTP.post( service_url, post_params ) ::Gitlab::ExternalAuthorization::Response.new(response) - rescue Excon::Error => e + rescue *Gitlab::HTTP::HTTP_ERRORS => e raise ::Gitlab::ExternalAuthorization::RequestFailed.new(e) end private + def allow_local_requests? + Gitlab::CurrentSettings.allow_local_requests_from_system_hooks? + end + def post_params params = { headers: REQUEST_HEADERS, body: body.to_json, connect_timeout: timeout, read_timeout: timeout, - write_timeout: timeout } + write_timeout: timeout, + allow_local_requests: allow_local_requests? } if has_tls? params[:client_cert_data] = client_cert diff --git a/lib/gitlab/external_authorization/response.rb b/lib/gitlab/external_authorization/response.rb index 04f9688fad0..8656065303d 100644 --- a/lib/gitlab/external_authorization/response.rb +++ b/lib/gitlab/external_authorization/response.rb @@ -5,16 +5,16 @@ module Gitlab class Response include ::Gitlab::Utils::StrongMemoize - def initialize(excon_response) - @excon_response = excon_response + def initialize(response) + @response = response end def valid? - @excon_response && [200, 401, 403].include?(@excon_response.status) + @response && [200, 401, 403].include?(@response.code) end def successful? - valid? && @excon_response.status == 200 + valid? && @response.code == 200 end def reason @@ -28,7 +28,7 @@ module Gitlab end def parse_response! - Gitlab::Json.parse(@excon_response.body) + Gitlab::Json.parse(@response.body) rescue JSON::JSONError # The JSON response is optional, so don't fail when it's missing nil |