redhat_access 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +24 -0
- data/LICENSE.txt +620 -0
- data/README.rdoc +7 -0
- data/Rakefile +131 -0
- data/app/assets/javascripts/insights/app.module.js +64 -0
- data/app/assets/javascripts/insights/application.js +18 -0
- data/app/assets/javascripts/insights/configuration.controller.js +66 -0
- data/app/assets/javascripts/insights/configuration.service.js +28 -0
- data/app/assets/javascripts/insights/views/configuration.html +85 -0
- data/app/assets/javascripts/insights/views/error.html +13 -0
- data/app/assets/javascripts/insights/views/help.html +16 -0
- data/app/assets/javascripts/redhat_access/analytics_dashboard.js +2 -0
- data/app/assets/javascripts/redhat_access/application.js +15 -0
- data/app/assets/javascripts/redhat_access/redhat_access.module.js +126 -0
- data/app/assets/stylesheets/insights/application.css +14 -0
- data/app/assets/stylesheets/insights/insights.css +21 -0
- data/app/assets/stylesheets/redhat_access/application.css +14 -0
- data/app/assets/stylesheets/redhat_access/telemetry_configuration.css +4 -0
- data/app/controllers/redhat_access/analytics_dashboard_controller.rb +12 -0
- data/app/controllers/redhat_access/api/api_controller.rb +24 -0
- data/app/controllers/redhat_access/api/attachments_controller.rb +40 -0
- data/app/controllers/redhat_access/api/logs_controller.rb +49 -0
- data/app/controllers/redhat_access/api/machine_telemetry_api_controller.rb +112 -0
- data/app/controllers/redhat_access/api/strata_proxy_controller.rb +81 -0
- data/app/controllers/redhat_access/api/telemetry_api_controller.rb +179 -0
- data/app/controllers/redhat_access/application_controller.rb +2 -0
- data/app/controllers/redhat_access/cases_controller.rb +14 -0
- data/app/controllers/redhat_access/configuration_controller.rb +21 -0
- data/app/controllers/redhat_access/log_viewer_controller.rb +9 -0
- data/app/controllers/redhat_access/redhat_access_controller.rb +8 -0
- data/app/controllers/redhat_access/search_controller.rb +9 -0
- data/app/controllers/redhat_access/strata_credentials_controller.rb +48 -0
- data/app/controllers/redhat_access/telemetry_configurations_controller.rb +38 -0
- data/app/controllers/redhat_access/telemetry_controller.rb +6 -0
- data/app/helpers/redhat_access/analytics_dashboard_helper.rb +13 -0
- data/app/helpers/redhat_access/application_helper.rb +4 -0
- data/app/helpers/redhat_access/attachments_helper.rb +4 -0
- data/app/helpers/redhat_access/cases_helper.rb +4 -0
- data/app/helpers/redhat_access/log_viewer_helper.rb +4 -0
- data/app/helpers/redhat_access/logs_helper.rb +4 -0
- data/app/helpers/redhat_access/redhat_access_helper.rb +4 -0
- data/app/helpers/redhat_access/search_helper.rb +4 -0
- data/app/helpers/redhat_access/telemetry_configuration_helper.rb +4 -0
- data/app/models/redhat_access/concerns/organization_extensions.rb +10 -0
- data/app/models/redhat_access/telemetry_configuration.rb +11 -0
- data/app/models/redhat_access/telemetry_proxy_credentials.rb +10 -0
- data/app/services/redhat_access/authentication/client_authentication.rb +80 -0
- data/app/services/redhat_access/telemetry/look_ups.rb +233 -0
- data/app/services/redhat_access/telemetry/portal_client.rb +39 -0
- data/app/views/redhat_access/analytics_dashboard/configuration.html.erb +85 -0
- data/app/views/redhat_access/analytics_dashboard/error.html.erb +13 -0
- data/app/views/redhat_access/analytics_dashboard/help.html.erb +16 -0
- data/app/views/redhat_access/analytics_dashboard/index.html.erb +69 -0
- data/app/views/redhat_access/analytics_dashboard/welcome.html.erb +8 -0
- data/app/views/redhat_access/redhat_access/index.html.erb +34 -0
- data/ca/rh_cert-api_chain.pem +74 -0
- data/config/config.yml.example +15 -0
- data/config/environments/development.rb +5 -0
- data/config/initializers/load_config.rb +5 -0
- data/config/mount_engine.rb +3 -0
- data/config/routes.rb +36 -0
- data/db/migrate/20141204161152_create_redhat_access_telemetry_proxy_credentials.rb +11 -0
- data/db/migrate/20150319153744_create_redhat_access_telemetry_configurations.rb +13 -0
- data/db/migrate/20160425175501_add_email_to_telemetry_configurations.rb +5 -0
- data/db/seeds.d/200-update-insights-roles.rb +11 -0
- data/lib/redhat_access/configuration.rb +8 -0
- data/lib/redhat_access/engine.rb +225 -0
- data/lib/redhat_access/sos_reports/generator.rb +58 -0
- data/lib/redhat_access/strata/client.rb +39 -0
- data/lib/redhat_access/version.rb +3 -0
- data/lib/redhat_access.rb +5 -0
- data/lib/tasks/redhat_access_tasks.rake +41 -0
- data/locale/Makefile +62 -0
- data/locale/de/LC_MESSAGES/redhat_access.mo +0 -0
- data/locale/de/redhat_access.po +589 -0
- data/locale/es/LC_MESSAGES/redhat_access.mo +0 -0
- data/locale/es/redhat_access.po +589 -0
- data/locale/fr/LC_MESSAGES/redhat_access.mo +0 -0
- data/locale/fr/redhat_access.po +593 -0
- data/locale/gemspec.rb +2 -0
- data/locale/it/LC_MESSAGES/redhat_access.mo +0 -0
- data/locale/it/redhat_access.po +589 -0
- data/locale/ja/LC_MESSAGES/redhat_access.mo +0 -0
- data/locale/ja/redhat_access.po +569 -0
- data/locale/ko/LC_MESSAGES/redhat_access.mo +0 -0
- data/locale/ko/redhat_access.po +570 -0
- data/locale/pt/LC_MESSAGES/redhat_access.mo +0 -0
- data/locale/pt/redhat_access.po +588 -0
- data/locale/redhat_access.pot +34 -0
- data/locale/ru/LC_MESSAGES/redhat_access.mo +0 -0
- data/locale/ru/redhat_access.po +580 -0
- data/locale/zh/LC_MESSAGES/redhat_access.mo +0 -0
- data/locale/zh/redhat_access.po +561 -0
- data/redhat_access.gemspec +30 -0
- data/script/rails +8 -0
- data/script/sos_reports/foreman_sosreport.pam +9 -0
- data/script/sos_reports/foreman_sosreport_console.apps +3 -0
- data/script/sos_reports/foreman_sosreport_wrapper.py +65 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/fixtures/redhat_access/telemetry_configurations.yml +11 -0
- data/test/fixtures/redhat_access/telemetry_proxy_credentials.yml +11 -0
- data/test/functional/redhat_access/analytics_dashboard_controller_test.rb +11 -0
- data/test/functional/redhat_access/attachments_controller_test.rb +11 -0
- data/test/functional/redhat_access/cases_controller_test.rb +16 -0
- data/test/functional/redhat_access/configuration_controller_test.rb +11 -0
- data/test/functional/redhat_access/log_viewer_controller_test.rb +11 -0
- data/test/functional/redhat_access/logs_controller_test.rb +9 -0
- data/test/functional/redhat_access/redhat_access_controller_test.rb +11 -0
- data/test/functional/redhat_access/search_controller_test.rb +11 -0
- data/test/functional/redhat_access/telemetry_configuration_controller_test.rb +26 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/redhat_access/telemetry_proxy_credentials_test.rb +9 -0
- data/test/redhat_access_test.rb +7 -0
- data/test/sos-report-test.rb +32 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/helpers/redhat_access/analytics_dashboard_helper_test.rb +6 -0
- data/test/unit/helpers/redhat_access/attachments_helper_test.rb +6 -0
- data/test/unit/helpers/redhat_access/cases_helper_test.rb +6 -0
- data/test/unit/helpers/redhat_access/log_viewer_helper_test.rb +6 -0
- data/test/unit/helpers/redhat_access/logs_helper_test.rb +6 -0
- data/test/unit/helpers/redhat_access/redhat_access_helper_test.rb +6 -0
- data/test/unit/helpers/redhat_access/search_helper_test.rb +6 -0
- data/test/unit/helpers/redhat_access/telemetry_configuration_helper_test.rb +6 -0
- data/test/unit/redhat_access/telemetry_configuration_test.rb +9 -0
- data/vendor/assets/fonts/fonts/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/fonts/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/fonts/fontawesome-webfont.svg +655 -0
- data/vendor/assets/fonts/fonts/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/fonts/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/fonts/icomoon.eot +0 -0
- data/vendor/assets/fonts/fonts/icomoon.svg +22 -0
- data/vendor/assets/fonts/fonts/icomoon.ttf +0 -0
- data/vendor/assets/fonts/fonts/icomoon.woff +0 -0
- data/vendor/assets/fonts/fonts/overpass_bold-web.eot +0 -0
- data/vendor/assets/fonts/fonts/overpass_bold-web.svg +454 -0
- data/vendor/assets/fonts/fonts/overpass_bold-web.ttf +0 -0
- data/vendor/assets/fonts/fonts/overpass_bold-web.woff +0 -0
- data/vendor/assets/fonts/fonts/overpass_light-webfont.eot +0 -0
- data/vendor/assets/fonts/fonts/overpass_light-webfont.svg +2105 -0
- data/vendor/assets/fonts/fonts/overpass_light-webfont.ttf +0 -0
- data/vendor/assets/fonts/fonts/overpass_light-webfont.woff +0 -0
- data/vendor/assets/fonts/fonts/overpass_regular-web.eot +0 -0
- data/vendor/assets/fonts/fonts/overpass_regular-web.svg +454 -0
- data/vendor/assets/fonts/fonts/overpass_regular-web.ttf +0 -0
- data/vendor/assets/fonts/fonts/overpass_regular-web.woff +0 -0
- data/vendor/assets/fonts/fonts/portalicons.eot +0 -0
- data/vendor/assets/fonts/fonts/portalicons.svg +145 -0
- data/vendor/assets/fonts/fonts/portalicons.ttf +0 -0
- data/vendor/assets/fonts/fonts/portalicons.woff +0 -0
- data/vendor/assets/images/images/Icon_RH_Document_Blueprint_RGB_Button.png +0 -0
- data/vendor/assets/images/images/Icon_RH_Misc_Lifestyle_RGB_Button.png +0 -0
- data/vendor/assets/images/images/Icon_RH_Software_Data_CMYK_Button.png +0 -0
- data/vendor/assets/images/images/Icon_RH_Software_Transfer-Upload_CMYK_Button.png +0 -0
- data/vendor/assets/images/images/bg1.jpg +0 -0
- data/vendor/assets/images/images/bg_body.jpg +0 -0
- data/vendor/assets/images/images/bg_chart-shadow.png +0 -0
- data/vendor/assets/images/images/bg_dount-hole-na.png +0 -0
- data/vendor/assets/images/images/bg_glow.jpg +0 -0
- data/vendor/assets/images/images/bg_pattern.png +0 -0
- data/vendor/assets/images/images/i_chart.png +0 -0
- data/vendor/assets/images/images/img-insights-connection-sat.png +0 -0
- data/vendor/assets/images/images/img-insights-connection.png +0 -0
- data/vendor/assets/images/images/img-sat5-step2-admin.png +0 -0
- data/vendor/assets/images/images/img-sat5-step3-completed.png +0 -0
- data/vendor/assets/images/images/img-sat5-step3-pending.png +0 -0
- data/vendor/assets/images/images/img-sat5-step3-setup.png +0 -0
- data/vendor/assets/images/images/img-sat5-step5-overview.png +0 -0
- data/vendor/assets/images/images/img-sat5-step5-reports.png +0 -0
- data/vendor/assets/images/images/img-sat5-step5-systems.png +0 -0
- data/vendor/assets/images/images/img-sat6-step2.jpg +0 -0
- data/vendor/assets/images/images/img-sat6-step3.jpg +0 -0
- data/vendor/assets/images/images/img-sat6-step3.png +0 -0
- data/vendor/assets/images/images/img-sat6-step4.jpg +0 -0
- data/vendor/assets/images/images/img-sat6-step5a.jpg +0 -0
- data/vendor/assets/images/images/img-sat6-step5b.jpg +0 -0
- data/vendor/assets/images/images/img-sat6-step5c.jpg +0 -0
- data/vendor/assets/images/images/img-sat6-step5d.jpg +0 -0
- data/vendor/assets/images/images/keynote-snap.jpg +0 -0
- data/vendor/assets/images/images/keynote-snap.png +0 -0
- data/vendor/assets/images/images/splash-gettingstarted.jpg +0 -0
- data/vendor/assets/images/images/splash-learnmore.jpg +0 -0
- data/vendor/assets/images/images/splash-security.jpg +0 -0
- data/vendor/assets/javascripts/angular/angular.js +20131 -0
- data/vendor/assets/javascripts/redhat_access/redhat_access_angular_ui-deps.js +14103 -0
- data/vendor/assets/javascripts/redhat_access/redhat_access_angular_ui.js +7854 -0
- data/vendor/assets/javascripts/telemetry/insights.js +39 -0
- data/vendor/assets/stylesheets/redhat_access/redhat_access_angular_ui-deps.css +11 -0
- data/vendor/assets/stylesheets/redhat_access/redhat_access_angular_ui.css +1 -0
- data/vendor/assets/stylesheets/telemetry/sat6.css +18 -0
- metadata +341 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module RedhatAccess
|
|
2
|
+
class TelemetryConfiguration < ActiveRecord::Base
|
|
3
|
+
include Encryptable
|
|
4
|
+
belongs_to :organization ,:class_name => "Organization", :inverse_of => :telemetry_configuration
|
|
5
|
+
encrypts :portal_password
|
|
6
|
+
self.include_root_in_json = false
|
|
7
|
+
def name
|
|
8
|
+
return "TelemetryConfiguration"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# This is code is based on the katello project
|
|
2
|
+
#
|
|
3
|
+
require 'active_support'
|
|
4
|
+
require 'openssl'
|
|
5
|
+
require 'base64'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
module RedhatAccess
|
|
9
|
+
module Authentication
|
|
10
|
+
module ClientAuthentication
|
|
11
|
+
|
|
12
|
+
def authenticate_client
|
|
13
|
+
set_client_user
|
|
14
|
+
require_login unless User.current
|
|
15
|
+
User.current.present?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def deny_access
|
|
19
|
+
render json: { :message => "Permission Denied." }, :status => 403
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def set_client_user
|
|
23
|
+
if cert_present?
|
|
24
|
+
client_cert = RedhatAccess::Authentication::Cert.new(cert_from_request)
|
|
25
|
+
uuid = client_cert.uuid
|
|
26
|
+
Rails.logger.debug("Client cert UUID is : #{uuid}")
|
|
27
|
+
User.current = CertUser.new(:login => uuid)
|
|
28
|
+
else
|
|
29
|
+
Rails.logger.debug("Client cert not present in request")
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def cert_present?
|
|
34
|
+
ssl_client_cert = cert_from_request
|
|
35
|
+
!ssl_client_cert.nil? && !ssl_client_cert.empty? && ssl_client_cert != "(null)"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def cert_from_request
|
|
39
|
+
request.env['HTTP_X_RHSM_SSL_CLIENT_CERT'] ||
|
|
40
|
+
request.env['SSL_CLIENT_CERT'] ||
|
|
41
|
+
request.env['HTTP_SSL_CLIENT_CERT'] ||
|
|
42
|
+
ENV['HTTP_X_RHSM_SSL_CLIENT_CERT'] ||
|
|
43
|
+
ENV['SSL_CLIENT_CERT'] ||
|
|
44
|
+
ENV['HTTP_SSL_CLIENT_CERT']
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class CertUser < ::User
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class Cert
|
|
52
|
+
attr_accessor :cert
|
|
53
|
+
def initialize(cert)
|
|
54
|
+
self.cert = extract(cert)
|
|
55
|
+
end
|
|
56
|
+
def uuid
|
|
57
|
+
drop_cn_prefix_from_subject(@cert.subject.to_s)
|
|
58
|
+
end
|
|
59
|
+
private
|
|
60
|
+
def extract(cert)
|
|
61
|
+
if cert.empty?
|
|
62
|
+
fail('Invalid cert provided. Ensure that the provided cert is not empty.')
|
|
63
|
+
else
|
|
64
|
+
cert = strip_cert(cert)
|
|
65
|
+
cert = Base64.decode64(cert)
|
|
66
|
+
OpenSSL::X509::Certificate.new(cert)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
def drop_cn_prefix_from_subject(subject_string)
|
|
70
|
+
subject_string.sub(/\/CN=/i, '')
|
|
71
|
+
end
|
|
72
|
+
def strip_cert(cert)
|
|
73
|
+
cert = cert.to_s.gsub("-----BEGIN CERTIFICATE-----", "").gsub("-----END CERTIFICATE-----", "")
|
|
74
|
+
cert.gsub!(' ', '')
|
|
75
|
+
cert.gsub!(/\n/, '')
|
|
76
|
+
cert
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
begin
|
|
2
|
+
# TODO: fix dirty hack
|
|
3
|
+
require '/usr/share/foreman/lib/satellite/version.rb'
|
|
4
|
+
rescue LoadError
|
|
5
|
+
# don't need to do anything
|
|
6
|
+
Rails.logger.debug("Unable to load version file.")
|
|
7
|
+
end
|
|
8
|
+
module RedhatAccess
|
|
9
|
+
module Telemetry
|
|
10
|
+
module LookUps
|
|
11
|
+
class RecordNotFound < StandardError
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def can_unregister_system(user)
|
|
15
|
+
# TODO: move this to an auth class?
|
|
16
|
+
return false if user.nil?
|
|
17
|
+
return true if user.admin
|
|
18
|
+
permissions = user.cached_roles.collect(&:permissions).flatten.map!(&:name)
|
|
19
|
+
# Rails.logger.debug("User can unregister telemetry hosts : #{ permissions.include?("rh_telemetry_configurations")}")
|
|
20
|
+
# for now we allow all.
|
|
21
|
+
true
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def can_mask_rules(user)
|
|
25
|
+
# #TODO move this to an auth class?
|
|
26
|
+
# TODO move this to an auth class?
|
|
27
|
+
return false if user.nil?
|
|
28
|
+
return true if user.admin
|
|
29
|
+
permissions = user.cached_roles.collect(&:permissions).flatten.map!(&:name)
|
|
30
|
+
Rails.logger.debug("User can mask telemetry hosts : #{permissions.include?("rh_telemetry_configurations")}")
|
|
31
|
+
permissions.include?("rh_telemetry_configurations")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def is_susbcribed_to_redhat?(org)
|
|
35
|
+
if org
|
|
36
|
+
upstream = org.owner_details['upstreamConsumer']
|
|
37
|
+
return upstream && upstream['idCert'] ? true : false
|
|
38
|
+
end
|
|
39
|
+
false
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def is_org_selected?
|
|
43
|
+
Organization.current.nil? ? false : true
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def get_telemetry_config(org)
|
|
47
|
+
TelemetryConfiguration.find_or_create_by(:organization_id => org.id) do |conf|
|
|
48
|
+
conf.enable_telemetry = true
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def telemetry_enabled?(org)
|
|
53
|
+
if org
|
|
54
|
+
conf = get_telemetry_config(org)
|
|
55
|
+
return conf.nil? ? false : conf.enable_telemetry
|
|
56
|
+
else
|
|
57
|
+
raise(RecordNotFound, 'Host not found or invalid')
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def telemetry_enabled_for_uuid?(uuid)
|
|
62
|
+
telemetry_enabled?(get_organization(uuid))
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def get_content_host_by_fqdn(name)
|
|
66
|
+
Katello::System.first(:conditions => {:name => name})
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def disconnected_org?(org)
|
|
70
|
+
if org
|
|
71
|
+
# TODO: fix hard coding
|
|
72
|
+
org.redhat_repository_url != 'https://cdn.redhat.com'
|
|
73
|
+
else
|
|
74
|
+
raise(RecordNotFound, 'Organization not found or invalid')
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def get_leaf_id(uuid)
|
|
79
|
+
system = get_content_host(uuid)
|
|
80
|
+
if system.nil?
|
|
81
|
+
ldebug('Host not found or invalid')
|
|
82
|
+
raise(RecordNotFound, 'Host not found or invalid')
|
|
83
|
+
end
|
|
84
|
+
uuid
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def get_branch_id_for_org(org)
|
|
88
|
+
if org
|
|
89
|
+
if !org.owner_details['upstreamConsumer'] || !org.owner_details['upstreamConsumer']['uuid']
|
|
90
|
+
# ldebug('Org manifest not found or invalid in get_branch_id')
|
|
91
|
+
raise(RecordNotFound, 'Branch ID not found for organization')
|
|
92
|
+
else
|
|
93
|
+
branch_id = org.owner_details['upstreamConsumer']['uuid']
|
|
94
|
+
end
|
|
95
|
+
else
|
|
96
|
+
raise(RecordNotFound, 'Organization not found or invalid')
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def get_ssl_options_for_uuid(uuid, ca_file)
|
|
101
|
+
org = get_organization(uuid)
|
|
102
|
+
get_ssl_options_for_org(org, ca_file)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def use_basic_auth?
|
|
106
|
+
REDHAT_ACCESS_CONFIG[:enable_telemetry_basic_auth]
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def get_ssl_options_for_org(org, ca_file)
|
|
110
|
+
if org
|
|
111
|
+
verify_peer = REDHAT_ACCESS_CONFIG[:telemetry_ssl_verify_peer] ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
|
112
|
+
ssl_version = REDHAT_ACCESS_CONFIG[:telemetry_ssl_verify_peer] ? REDHAT_ACCESS_CONFIG[:telemetry_ssl_verify_peer] : nil
|
|
113
|
+
ca_file = ca_file ? ca_file : get_default_ssl_ca_file
|
|
114
|
+
Rails.logger.debug("Verify peer #{verify_peer}")
|
|
115
|
+
if use_basic_auth?
|
|
116
|
+
Rails.logger.debug("Using basic auth for portal communication")
|
|
117
|
+
get_basic_auth_options(org, ca_file, verify_peer, ssl_version)
|
|
118
|
+
else
|
|
119
|
+
Rails.logger.debug("Using SSL auth for portal communication")
|
|
120
|
+
get_mutual_tls_auth_options(org, ca_file, verify_peer, ssl_version)
|
|
121
|
+
end
|
|
122
|
+
else
|
|
123
|
+
raise(RecordNotFound, 'Organization not found or invalid')
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def get_default_ssl_ca_file
|
|
128
|
+
"#{RedhatAccess::Engine.root}/ca/rh_cert-api_chain.pem"
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def get_mutual_tls_auth_options(org, ca_file, verify_peer, ssl_version)
|
|
132
|
+
upstream = org.owner_details['upstreamConsumer']
|
|
133
|
+
if !upstream || !upstream['idCert'] || !upstream['idCert']['cert'] || !upstream['idCert']['key']
|
|
134
|
+
raise(RecordNotFound, 'Unable to get portal SSL credentials. Missing org manifest?')
|
|
135
|
+
else
|
|
136
|
+
opts = {
|
|
137
|
+
:ssl_client_cert => OpenSSL::X509::Certificate.new(upstream['idCert']['cert']),
|
|
138
|
+
:ssl_client_key => OpenSSL::PKey::RSA.new(upstream['idCert']['key']),
|
|
139
|
+
:ssl_ca_file => ca_file,
|
|
140
|
+
:verify_ssl => verify_peer
|
|
141
|
+
}
|
|
142
|
+
opts[:ssl_version] = ssl_version if ssl_version
|
|
143
|
+
Rails.logger.debug("Telemetry ssl options => ca_file:#{opts[:ssl_ca_file]} , peer verify #{opts[:verify_ssl]}")
|
|
144
|
+
opts
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def get_basic_auth_options(org, ca_file, verify_peer, ssl_version)
|
|
149
|
+
opts = {
|
|
150
|
+
:user => org.telemetry_configuration.portal_user,
|
|
151
|
+
:password => org.telemetry_configuration.portal_password,
|
|
152
|
+
:ssl_ca_file => ca_file,
|
|
153
|
+
:verify_ssl => verify_peer
|
|
154
|
+
}
|
|
155
|
+
opts[:ssl_version] = ssl_version if ssl_version
|
|
156
|
+
opts
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def get_branch_id_for_uuid(uuid)
|
|
160
|
+
org = get_organization(uuid)
|
|
161
|
+
get_branch_id_for_org org
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def get_organization(uuid)
|
|
165
|
+
system = get_content_host(uuid)
|
|
166
|
+
system.nil? ? nil : system.organization
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def get_content_host(uuid = nil)
|
|
170
|
+
uuid ||= params[:id]
|
|
171
|
+
facet = Katello::Host::SubscriptionFacet.where(:uuid => uuid).first
|
|
172
|
+
if facet.nil?
|
|
173
|
+
User.as_anonymous_admin { Resources::Candlepin::Consumer.get(uuid) }
|
|
174
|
+
raise HttpErrors::NotFound, _("Couldn't find consumer '%s'") % uuid
|
|
175
|
+
end
|
|
176
|
+
@host = facet.host
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def get_content_hosts(org)
|
|
180
|
+
if org
|
|
181
|
+
org_id = org.id
|
|
182
|
+
environment_ids = Organization.find(org_id).kt_environments.pluck(:id)
|
|
183
|
+
hosts = Katello::System.readable.where(:environment_id => environment_ids).pluck(:uuid).compact.sort
|
|
184
|
+
else
|
|
185
|
+
raise(RecordNotFound, 'Organization not found or invalid')
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def get_portal_http_proxy
|
|
190
|
+
proxy = nil
|
|
191
|
+
if SETTINGS[:katello][:cdn_proxy] && SETTINGS[:katello][:cdn_proxy][:host]
|
|
192
|
+
proxy_config = SETTINGS[:katello][:cdn_proxy]
|
|
193
|
+
uri = URI('')
|
|
194
|
+
uri.scheme = URI.parse(proxy_config[:host]).scheme
|
|
195
|
+
uri.host = URI.parse(proxy_config[:host]).host
|
|
196
|
+
uri.port = proxy_config[:port] if proxy_config[:port]
|
|
197
|
+
uri.user = ERB::Util.url_encode(proxy_config[:user]) if proxy_config[:user]
|
|
198
|
+
uri.password = ERB::Util.url_encode(proxy_config[:password]) if proxy_config[:password]
|
|
199
|
+
proxy = uri.to_s
|
|
200
|
+
end
|
|
201
|
+
proxy
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# TODO: move version and name methods to generic utility
|
|
205
|
+
def get_rha_plugin_name
|
|
206
|
+
'redhat_access'
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def get_rha_plugin_rpm_name
|
|
210
|
+
'foreman-redhat_access'
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def get_rha_plugin_version
|
|
215
|
+
RedhatAccess::VERSION
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def get_plugin_parent_name
|
|
219
|
+
if defined? ForemanThemeSatellite::SATELLITE_VERSION
|
|
220
|
+
return 'Satellite'
|
|
221
|
+
end
|
|
222
|
+
'Foreman'
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def get_plugin_parent_version
|
|
226
|
+
if defined? ForemanThemeSatellite::SATELLITE_VERSION
|
|
227
|
+
return ForemanThemeSatellite::SATELLITE_VERSION.gsub(/[a-zA-Z ]/, "")
|
|
228
|
+
end
|
|
229
|
+
Foreman::Version.new.to_s
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'redhat_access_lib'
|
|
2
|
+
|
|
3
|
+
module RedhatAccess
|
|
4
|
+
module Telemetry
|
|
5
|
+
class PortalClient < RedHatSupportLib::TelemetryApi::Client
|
|
6
|
+
|
|
7
|
+
include RedhatAccess::Telemetry::LookUps
|
|
8
|
+
|
|
9
|
+
def initialize(upload_url,api_url, creds, context, optional)
|
|
10
|
+
super(upload_url,api_url, creds, optional)
|
|
11
|
+
@context = context
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get_machines
|
|
15
|
+
@context.get_machines
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Returns the branch id of the current org/account
|
|
19
|
+
def get_branch_id
|
|
20
|
+
return get_branch_id_for_org(Organization.current)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def get_auth_opts(creds)
|
|
24
|
+
# #temp implementation##########################
|
|
25
|
+
# if creds.is_a?(User) and User.current.is_a? RedhatAccess::Authentication::CertUser
|
|
26
|
+
# opts = get_ssl_options_for_uuid(User.current.login)
|
|
27
|
+
# elsif creds.is_a?(TelemetryProxyCredentials)
|
|
28
|
+
# opts = {
|
|
29
|
+
# :user => creds.username,
|
|
30
|
+
# :password => creds.password
|
|
31
|
+
# }
|
|
32
|
+
# end
|
|
33
|
+
#end temp implementation######################
|
|
34
|
+
#TODO enable below for cert based auth
|
|
35
|
+
return @context.get_auth_opts()
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<div class="section">
|
|
2
|
+
<div class="row margin-top">
|
|
3
|
+
<div class="col-sm-12">
|
|
4
|
+
<h1 class="page-title">Manage</h1>
|
|
5
|
+
</div>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="row row-short">
|
|
8
|
+
<div class="col-sm-12">
|
|
9
|
+
<div class="panel panel-default">
|
|
10
|
+
<div class="panel-heading">Access Insights Service Configuration</div>
|
|
11
|
+
<div>
|
|
12
|
+
<i ng-show="loading" class="fa fa-spinner fa-spin fa-1-5x"></i>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="panel-body">
|
|
15
|
+
<form class="form-horizontal">
|
|
16
|
+
<div class="form-group">
|
|
17
|
+
<label for="rha-insights-enabled" class="col-lg-3 control-label">Enable Service </label>
|
|
18
|
+
<div class="col-lg-6">
|
|
19
|
+
<div class="checkbox">
|
|
20
|
+
<input id="rha-insights-enabled" type="checkbox" ng-model="config.enable_telemetry" ng-disabled="loading" />
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="form-group" ng-show="env.enableBasicAuth">
|
|
25
|
+
<label for="rha-insights-password" class="col-lg-3 control-label">Customer Portal Username</label>
|
|
26
|
+
<div class="col-lg-6">
|
|
27
|
+
<input id="rha-insights-password" type="text" size="32" ng-model="config.portal_user" ng-disabled="loading" class="form-control" />
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="form-group" ng-show="env.enableBasicAuth">
|
|
31
|
+
<label for="rha-insights-password" class="col-lg-3 control-label">Customer Portal Password</label>
|
|
32
|
+
<div class="col-lg-6">
|
|
33
|
+
<input id="rha-insights-password" type="password" size="32" ng-model="config.portal_password" ng-disabled="loading" class="form-control" />
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="form-group">
|
|
37
|
+
<div class="col-lg-offset-3 col-lg-6">
|
|
38
|
+
<input type="submit" value="Save" ng-click="update()" ng-hide="disableUpdateButton()" class="btn btn-success" />
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</form>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<div class="panel panel-default" ng-show="showConnectionStatus()">
|
|
45
|
+
<div class="panel-heading">Insights Engine Connection</div>
|
|
46
|
+
<div>
|
|
47
|
+
<i ng-show="accountLoading" class="fa fa-spinner fa-spin fa-1-5x"></i>
|
|
48
|
+
</div>
|
|
49
|
+
<div class="panel-body">
|
|
50
|
+
<form class="form-horizontal">
|
|
51
|
+
<div class="form-group">
|
|
52
|
+
<label class="control-label col-sm-2" for="connectionStatus">Status:</label>
|
|
53
|
+
<div class="col-sm-10">
|
|
54
|
+
<p class="form-control-static"> {{portalAccount.connectionStatus}} </p>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
<div class="form-group">
|
|
58
|
+
<label class="control-label col-sm-2" for="account">Account Number:</label>
|
|
59
|
+
<div class="col-sm-10">
|
|
60
|
+
<p class="form-control-static">{{portalAccount.account}}</p>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
<div class="form-group" ng-show="portalAccount.company">
|
|
64
|
+
<label class="control-label col-sm-2" for="company">Company:</label>
|
|
65
|
+
<div class="col-sm-10">
|
|
66
|
+
<p class="form-control-static"> {{portalAccount.company}} </p>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
<div class="form-group" ng-show="portalAccount.orgId">
|
|
70
|
+
<label class="control-label col-sm-2" for="orgid">Organization ID:</label>
|
|
71
|
+
<div class="col-sm-10">
|
|
72
|
+
<p class="form-control-static"> {{portalAccount.orgId}} </p>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="form-group">
|
|
76
|
+
<div class="col-sm-offset-2 col-sm-2">
|
|
77
|
+
<input type="submit" value="Check Connection" ng-click="getAccountInfo()" ng-hide="accountLoading" class="btn btn-success" />
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</form>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<div class="section">
|
|
2
|
+
<section>
|
|
3
|
+
<h3>
|
|
4
|
+
<i ng-class="severityClass" class="fa i-error fa-times-circle"></i>
|
|
5
|
+
Error communicating with Red Hat Access Insights Service
|
|
6
|
+
</h3>
|
|
7
|
+
<p></p>
|
|
8
|
+
<p>
|
|
9
|
+
Please verify that you hava a valid subscription manifest in your organization and that your Satellite server is configured to allow HTTPS communications to <i>cert-api.redhat.access.com</i>.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
</section>
|
|
13
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<div class="section">
|
|
2
|
+
<section>
|
|
3
|
+
<h3>
|
|
4
|
+
General Information
|
|
5
|
+
</h3>
|
|
6
|
+
<p>
|
|
7
|
+
For an overview of the Red Hat Insights service, please refer to the <a href="https://access.redhat.com/insights/info/" target="_blank">general information page</a>.
|
|
8
|
+
</p>
|
|
9
|
+
<h3>
|
|
10
|
+
Getting Started
|
|
11
|
+
</h3>
|
|
12
|
+
<p>
|
|
13
|
+
For help with configuring and enabling the Red Hat Insights service in Satellite 6, please refer to the <a href="https://access.redhat.com/insights/getting-started/satellite/6/" target="_blank">Getting Started Guide</a>.
|
|
14
|
+
</p>
|
|
15
|
+
</section>
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<% if ((!help_path? && !manage_path?) || (manage_path? && !is_org_selected?)) && (!is_org_selected? || !telemetry_enabled?(Organization.current) || !is_susbcribed_to_redhat?(Organization.current) || disconnected_org?(Organization.current)) %>
|
|
2
|
+
<article id='content'>
|
|
3
|
+
<%if !is_org_selected? && !help_path %>
|
|
4
|
+
<section>
|
|
5
|
+
<h1>
|
|
6
|
+
<%= _("Organization Selection Required") %>
|
|
7
|
+
</h1>
|
|
8
|
+
<p>
|
|
9
|
+
<%= _("Please choose an organization using the selector located at the far left of the menu.") %>
|
|
10
|
+
</p>
|
|
11
|
+
</section>
|
|
12
|
+
<%elsif !telemetry_enabled?(Organization.current) %>
|
|
13
|
+
<section>
|
|
14
|
+
<h1>
|
|
15
|
+
<%= _("The Red Hat Insights service is disabled for this organization.") %>
|
|
16
|
+
</h1>
|
|
17
|
+
<p>
|
|
18
|
+
<%= _("Please contact your organization's administrator to enable the service.") %>
|
|
19
|
+
</p>
|
|
20
|
+
</section>
|
|
21
|
+
<%elsif !is_susbcribed_to_redhat?(Organization.current) %>
|
|
22
|
+
<section>
|
|
23
|
+
<h1>
|
|
24
|
+
<%= _("No Red Hat Subscriptions found!") %>
|
|
25
|
+
</h1>
|
|
26
|
+
<p>
|
|
27
|
+
<%= (_("A Red Hat Subscription is required to access this service, please import a manifest <a href='/subscriptions' data-no-turbolink>here</a>.")).html_safe %>
|
|
28
|
+
</p>
|
|
29
|
+
</section>
|
|
30
|
+
<%else%>
|
|
31
|
+
<section>
|
|
32
|
+
<h1>
|
|
33
|
+
<%= _("Organization is configured in disconnected mode.") %>
|
|
34
|
+
</h1>
|
|
35
|
+
<p>
|
|
36
|
+
<%= _("A network connection to the Red Hat Customer portal is required for this feature.")%>
|
|
37
|
+
</p>
|
|
38
|
+
</section>
|
|
39
|
+
<%end%>
|
|
40
|
+
</article>
|
|
41
|
+
<%else%>
|
|
42
|
+
<% content_for(:head) do %>
|
|
43
|
+
<base href="/redhat_access/insights/"/>
|
|
44
|
+
|
|
45
|
+
<% end %>
|
|
46
|
+
<div class="container main-content insights-main-content insights-app-overview">
|
|
47
|
+
<div class="form-group">
|
|
48
|
+
<h1><%= 'Red Hat Insights' %></h1>
|
|
49
|
+
</div>
|
|
50
|
+
<div ng-app="RedhatAccessInsights">
|
|
51
|
+
<div ui-view="" class="wrapper ng-cloak in-prod"></div>
|
|
52
|
+
<actionbar></actionbar>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<% content_for(:stylesheets) do %>
|
|
56
|
+
<%= stylesheet "insights/application" %>
|
|
57
|
+
<% end %>
|
|
58
|
+
<% content_for(:javascripts) do %>
|
|
59
|
+
<%= javascript_tag do %>
|
|
60
|
+
var REDHAT_ACCESS_SETTINGS = REDHAT_ACCESS_SETTINGS || {};
|
|
61
|
+
REDHAT_ACCESS_SETTINGS.Insights = {};
|
|
62
|
+
REDHAT_ACCESS_SETTINGS.Insights.allowBasicAuth = <%= REDHAT_ACCESS_CONFIG[:enable_telemetry_basic_auth] %> ;
|
|
63
|
+
REDHAT_ACCESS_SETTINGS.Insights.canUnregisterSystems = <%= can_unregister_system(User.current) %>;
|
|
64
|
+
REDHAT_ACCESS_SETTINGS.Insights.canIgnoreRules = <%= can_mask_rules(User.current) %>;
|
|
65
|
+
REDHAT_ACCESS_SETTINGS.currentLocale = '<%= (I18n.locale)[0..1] %>';
|
|
66
|
+
<%end%>
|
|
67
|
+
<%= javascript_include_tag "insights/application" %>
|
|
68
|
+
<% end %>
|
|
69
|
+
<%end%>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<% content_for(:head) do %>
|
|
2
|
+
<base href="/redhat_access/"/>
|
|
3
|
+
<% end %>
|
|
4
|
+
<div ng-app="RedhatAccess">
|
|
5
|
+
<div ui-view autoscroll="false"></div>
|
|
6
|
+
</div>
|
|
7
|
+
<%= stylesheet_link_tag 'redhat_access/application'%>
|
|
8
|
+
<%= javascript_include_tag 'redhat_access/application' %>
|
|
9
|
+
<%= javascript_tag do %>
|
|
10
|
+
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
|
|
11
|
+
var strataHost = "<%= REDHAT_ACCESS_CONFIG[:strata_host] %>";
|
|
12
|
+
var strataUrlPrefix = 'https://api.'+strataHost + '/';
|
|
13
|
+
var strataProxyUrl = window.location.protocol +"//"+ window.location.hostname + ':'+ window.location.port + '/redhat_access/strata/';
|
|
14
|
+
if (options.url.startsWith(strataUrlPrefix)){
|
|
15
|
+
var s = options.url.replace(strataUrlPrefix, strataProxyUrl);
|
|
16
|
+
options.url = options.url.replace(strataUrlPrefix, strataProxyUrl);
|
|
17
|
+
options.crossDomain = false;
|
|
18
|
+
}
|
|
19
|
+
if (options.url.startsWith(strataProxyUrl)){ //option.crossDomain check not reliable
|
|
20
|
+
var token = $('meta[name="csrf-token"]').attr('content');
|
|
21
|
+
if (token) {
|
|
22
|
+
return jqXHR.setRequestHeader('X-CSRF-Token', token);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
$(document).on('ajaxError', function(event, xhr) {
|
|
27
|
+
if (xhr.status === 401 || xhr.status === 403) {
|
|
28
|
+
window.location.href = "/users/login";
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
angular.module('RedhatAccess').value('currentLocale', '<%= (I18n.locale)[0..1] %>');
|
|
32
|
+
strata.setPortalHostname('<%= REDHAT_ACCESS_CONFIG[:strata_host] %>');
|
|
33
|
+
strata.setRedhatClientID('<%= "foreman_plugin_#{REDHAT_ACCESS_CONFIG[:deployment]}_#{RedhatAccess::VERSION}" %>');
|
|
34
|
+
<% end %>
|