Sha256: d1fc5dc868f4d094d45a0ba502c339a30157a5baa4990b6b98caa47d167351b4

Contents?: true

Size: 750 Bytes

Versions: 14

Compression:

Stored size: 750 Bytes

Contents

# frozen_string_literal: true

module ApiAuthorizer
  extend ActiveSupport::Concern

  included do
    before_action :hosts_permission
  end

  private

  def hosts_permission
    return if User.current.can?('view_hosts')

    render_error 'access_denied', status: :forbidden,
                                  locals: { details: _('Missing one of the required permissions: view_hosts'),
                                            missing_permissions: 'view_hosts' }
  end

  def resource_scope(_options = {})
    @resource_scope ||= begin
      scope = PreupgradeReport.joins(:host).merge(Host.authorized(:view_hosts, Host))
      scope = scope.where(job_invocation_id: params[:id]) if action_name == 'job_invocation'
      scope
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
foreman_leapp-0.1.13 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.12 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.11 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.10 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.9 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.8 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.7 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.6 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.5 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.4 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.3 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.2 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.1 app/controllers/api/v2/concerns/api_authorizer.rb
foreman_leapp-0.1.0 app/controllers/api/v2/concerns/api_authorizer.rb