diff options
author | Luke Kanies <luke@madstop.com> | 2008-05-27 07:20:56 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-06-09 16:39:25 -0500 |
commit | e8044f93efd29fab87d67f55461df371dec8bdff (patch) | |
tree | 6de696a9cc81c370a0537df9ba9eef6013bb939e /lib/puppet/indirector/request.rb | |
parent | dbd9b40c6537c261f01976238ef9ccfd6a6d6d08 (diff) | |
download | puppet-e8044f93efd29fab87d67f55461df371dec8bdff.tar.gz puppet-e8044f93efd29fab87d67f55461df371dec8bdff.tar.xz puppet-e8044f93efd29fab87d67f55461df371dec8bdff.zip |
Adding to the indirection request support for authentication information.
This basically consists of the node name (i.e., the certificate name),
the IP, and whether the request is authenticated (which is determined
by whether it provided a valid certificate).
Now the two REST classes (mongrel and webrick) need to correctly
pass this information to the indirection calls they make.
Diffstat (limited to 'lib/puppet/indirector/request.rb')
-rw-r--r-- | lib/puppet/indirector/request.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb index 68b7ee160..45c06670b 100644 --- a/lib/puppet/indirector/request.rb +++ b/lib/puppet/indirector/request.rb @@ -3,10 +3,28 @@ require 'puppet/indirector' # Provide any attributes or functionality needed for indirected # instances. class Puppet::Indirector::Request - attr_accessor :indirection_name, :key, :method, :options, :instance + attr_accessor :indirection_name, :key, :method, :options, :instance, :node, :ip, :authenticated + + # Is this an authenticated request? + def authenticated? + # Double negative, so we just get true or false + ! ! authenticated + end def initialize(indirection_name, method, key, options = {}) - @indirection_name, @method, @options = indirection_name, method, (options || {}) + options ||= {} + raise ArgumentError, "Request options must be a hash, not %s" % options.class unless options.is_a?(Hash) + + @indirection_name, @method = indirection_name, method + + @options = options.inject({}) do |result, ary| + param, value = ary + if respond_to?(param.to_s + "=") + send(param.to_s + "=", value) + else + result[param] = value + end + end if key.is_a?(String) or key.is_a?(Symbol) @key = key @@ -14,8 +32,6 @@ class Puppet::Indirector::Request @instance = key @key = @instance.name end - - raise ArgumentError, "Request options must be a hash, not %s" % @options.class unless @options.is_a?(Hash) end # Look up the indirection based on the name provided. |