projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '12902-queued-to-cancelled'
[arvados.git]
/
apps
/
workbench
/
app
/
models
/
arvados_api_client.rb
diff --git
a/apps/workbench/app/models/arvados_api_client.rb
b/apps/workbench/app/models/arvados_api_client.rb
index 4d549d194728eb00a9f3a2a01fd097d84955a16e..5a8fd518d386ec89125552c9fe17730e0488d4c4 100644
(file)
--- a/
apps/workbench/app/models/arvados_api_client.rb
+++ b/
apps/workbench/app/models/arvados_api_client.rb
@@
-1,3
+1,7
@@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
require 'httpclient'
require 'thread'
require 'httpclient'
require 'thread'
@@
-78,18
+82,24
@@
class ArvadosApiClient
@client_mtx = Mutex.new
end
@client_mtx = Mutex.new
end
- def api(resources_kind, action, data=nil, tokens={})
+ def api(resources_kind, action, data=nil, tokens={}
, include_anon_token=true
)
profile_checkpoint
if not @api_client
@client_mtx.synchronize do
@api_client = HTTPClient.new
profile_checkpoint
if not @api_client
@client_mtx.synchronize do
@api_client = HTTPClient.new
+ @api_client.ssl_config.timeout = Rails.configuration.api_client_connect_timeout
+ @api_client.connect_timeout = Rails.configuration.api_client_connect_timeout
+ @api_client.receive_timeout = Rails.configuration.api_client_receive_timeout
if Rails.configuration.arvados_insecure_https
@api_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
else
# Use system CA certificates
if Rails.configuration.arvados_insecure_https
@api_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
else
# Use system CA certificates
- @api_client.ssl_config.add_trust_ca('/etc/ssl/certs')
+ ["/etc/ssl/certs/ca-certificates.crt",
+ "/etc/pki/tls/certs/ca-bundle.crt"]
+ .select { |ca_path| File.readable?(ca_path) }
+ .each { |ca_path| @api_client.ssl_config.add_trust_ca(ca_path) }
end
if Rails.configuration.api_response_compression
@api_client.transparent_gzip_decompression = true
end
if Rails.configuration.api_response_compression
@api_client.transparent_gzip_decompression = true
@@
-104,13
+114,10
@@
class ArvadosApiClient
url.sub! '/arvados/v1/../../', '/'
query = {
url.sub! '/arvados/v1/../../', '/'
query = {
- 'api_token' => (tokens[:arvados_api_token] ||
- Thread.current[:arvados_api_token] ||
- ''),
'reader_tokens' => ((tokens[:reader_tokens] ||
Thread.current[:reader_tokens] ||
[]) +
'reader_tokens' => ((tokens[:reader_tokens] ||
Thread.current[:reader_tokens] ||
[]) +
-
[Rails.configuration.anonymous_user_token]
).to_json,
+
(include_anon_token ? [Rails.configuration.anonymous_user_token] : [])
).to_json,
}
if !data.nil?
data.each do |k,v|
}
if !data.nil?
data.each do |k,v|
@@
-132,12
+139,19
@@
class ArvadosApiClient
query["_profile"] = "true"
end
query["_profile"] = "true"
end
- header = {"Accept" => "application/json"}
+ headers = {
+ "Accept" => "application/json",
+ "Authorization" => "OAuth2 " +
+ (tokens[:arvados_api_token] ||
+ Thread.current[:arvados_api_token] ||
+ ''),
+ "X-Request-Id" => Thread.current[:request_id] || '',
+ }
profile_checkpoint { "Prepare request #{query["_method"] or "POST"} #{url} #{query[:uuid]} #{query.inspect[0,256]}" }
msg = @client_mtx.synchronize do
begin
profile_checkpoint { "Prepare request #{query["_method"] or "POST"} #{url} #{query[:uuid]} #{query.inspect[0,256]}" }
msg = @client_mtx.synchronize do
begin
- @api_client.post(url, query, header
: header
)
+ @api_client.post(url, query, header
s
)
rescue => exception
raise NoApiResponseException.new(url, exception)
end
rescue => exception
raise NoApiResponseException.new(url, exception)
end