Class: Puppet::Network::HTTP::API::Master::V3::Authorization

Inherits:
Object
  • Object
show all
Includes:
Authorization
Defined in:
lib/puppet/network/http/api/master/v3/authorization.rb

Instance Method Summary collapse

Methods included from Authorization

#authconfig, authconfigloader_class=, #check_authorization

Instance Method Details

#wrap(&block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/puppet/network/http/api/master/v3/authorization.rb', line 6

def wrap(&block)
  lambda do |request, response|
    begin
      authconfig.check_authorization(:find, request.path, request.params)
    rescue Puppet::Network::AuthorizationError => e
      raise Puppet::Network::HTTP::Error::HTTPNotAuthorizedError.new(e.message, Puppet::Network::HTTP::Issues::FAILED_AUTHORIZATION)
    end

    block.call.call(request, response)
  end
end