Module: InsightsCloud::ClientAuthentication

Extended by:
ActiveSupport::Concern
Includes:
Katello::Authentication::ClientAuthentication
Included in:
Api::MachineTelemetriesController
Defined in:
app/controllers/concerns/insights_cloud/client_authentication.rb

Instance Method Summary collapse

Instance Method Details

#authorizeObject



7
8
9
# File 'app/controllers/concerns/insights_cloud/client_authentication.rb', line 7

def authorize
  client_authorized? || super
end

#client_authorized?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/controllers/concerns/insights_cloud/client_authentication.rb', line 11

def client_authorized?
  authenticate_client && valid_machine_user?
end

#subscribed_host_by_uuid(uuid) ⇒ Object



19
20
21
# File 'app/controllers/concerns/insights_cloud/client_authentication.rb', line 19

def subscribed_host_by_uuid(uuid)
  @host = Host.unscoped.joins(:subscription_facet).where(:katello_subscription_facets => { :uuid => uuid }).first
end

#valid_machine_user?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/controllers/concerns/insights_cloud/client_authentication.rb', line 15

def valid_machine_user?
  subscribed_host_by_uuid(User.current.uuid).present?
end