Class: Puppet::Network::HTTP::API::V2::Authorization

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

Instance Method Summary collapse

Methods included from Authorization

#authconfig, #check_authorization

Instance Method Details

#call(request, response) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/puppet/network/http/api/v2/authorization.rb', line 4

def call(request, response)
  if request.method != "GET"
    raise Puppet::Network::HTTP::Error::HTTPNotAuthorizedError.new("Only GET requests are authorized for V2 endpoints", Puppet::Network::HTTP::Issues::UNSUPPORTED_METHOD)
  end

  begin
    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
end