Revision b8d29217
Added by Martin Milata over 9 years ago
app/helpers/abrt_reports_helper.rb | ||
---|---|---|
attr_reader :path, :content_type
|
||
end
|
||
|
||
def send_to_abrt_server(abrt_report)
|
||
def send_to_abrt_server(abrt_report, username = nil, password = nil)
|
||
request_params = {
|
||
:timeout => 60,
|
||
:open_timeout => 10,
|
||
... | ... | |
request_params[:ssl_client_key] = OpenSSL::PKey::RSA.new(File.read(Setting[:abrt_server_ssl_priv_key]))
|
||
end
|
||
|
||
# basic auth
|
||
if username && password
|
||
request_params[:user] = username
|
||
request_params[:password] = password
|
||
end
|
||
|
||
resource = RestClient::Resource.new(Setting[:abrt_server_url], request_params)
|
||
report_file = StringIOWithPath.new(abrt_report.json, '*buffer*', 'application/json')
|
||
response = resource['reports/new/'].post({ :file => report_file, :multipart => true }, :content_type => :json, :accept => :json)
|
||
... | ... | |
reason
|
||
end
|
||
end
|
||
|
||
def using_redhat_server
|
||
match = %r{^https://[^/]*access\.redhat\.com/}.match(Setting[:abrt_server_url])
|
||
!!match
|
||
end
|
||
|
||
def display_forward_button(abrt_report)
|
||
if Setting[:abrt_server_requires_basic_auth] || using_redhat_server
|
||
button_tag _('Send for analysis'), :id => 'forward_auth_button', :class => 'btn btn-success'
|
||
else
|
||
options = { :class => 'btn btn-success', :method => :post }
|
||
if abrt_report.forwarded_at
|
||
options[:confirm] = _('The report has already been sent. Sending it again will overwrite the previous response.')
|
||
end
|
||
link_to _('Send for analysis'), forward_abrt_report_path(abrt_report), options
|
||
end
|
||
end
|
||
|
||
def forward_auth_title
|
||
if using_redhat_server
|
||
_('Please provide Red Hat Customer Portal credentials')
|
||
else
|
||
_('Please provide ABRT server credentials')
|
||
end
|
||
end
|
||
|
||
def forward_auth_login
|
||
if using_redhat_server
|
||
_('Red Hat Login')
|
||
else
|
||
_('Login')
|
||
end
|
||
end
|
||
|
||
def forward_auth_text
|
||
if using_redhat_server
|
||
_('The problem report will be sent to Red Hat in order to determine if a solution exists. '\
|
||
'You need to provide your Red Hat Customer Portal login and password in order to proceed.')
|
||
else
|
||
_('Your ABRT server is configured to require login and password.')
|
||
end
|
||
end
|
||
end
|
Also available in: Unified diff
Implement HTTP basic auth for forwarding reports