File: authorization.rb

package info (click to toggle)
puppet-agent 8.10.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,404 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (21 lines) | stat: -rw-r--r-- 733 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module Puppet::Network
  module Authorization
    class << self
      # This method is deprecated and will be removed in a future release.
      def authconfigloader_class=(klass)
        @authconfigloader_class = klass
      end

      # Verify something external to puppet is authorizing REST requests, so
      # we don't fail insecurely due to misconfiguration.
      def check_external_authorization(method, path)
        if @authconfigloader_class.nil?
          message = "Forbidden request: #{path} (method #{method})"
          raise Puppet::Network::HTTP::Error::HTTPNotAuthorizedError.new(message, Puppet::Network::HTTP::Issues::FAILED_AUTHORIZATION)
        end
      end
    end
  end
end