Class Puppet::Network::AuthConfig
In: lib/puppet/network/authconfig.rb
Parent: Puppet::Util::LoadedFile

Methods

allowed?   exists?   main   new   read  

Public Class methods

[Source]

    # File lib/puppet/network/authconfig.rb, line 8
 8:         def self.main
 9:             unless defined? @main
10:                 @main = self.new()
11:             end
12:             @main
13:         end

[Source]

    # File lib/puppet/network/authconfig.rb, line 46
46:         def initialize(file = nil, parsenow = true)
47:             @file ||= Puppet[:authconfig]
48: 
49:             unless @file
50:                 raise Puppet::DevError, "No authconfig file defined"
51:             end
52:             return unless self.exists?
53:             super(@file)
54:             @rights = Puppet::Network::Rights.new
55:             @configstamp = @configstatted = nil
56:             @configtimeout = 60
57: 
58:             if parsenow
59:                 read()
60:             end
61:         end

Public Instance methods

Here we add a little bit of semantics. They can set auth on a whole namespace or on just a single method in the namespace.

[Source]

    # File lib/puppet/network/authconfig.rb, line 24
24:         def allowed?(request)
25:             name        = request.call.intern
26:             namespace   = request.handler.intern
27:             method      = request.method.intern
28: 
29:             read()
30: 
31:             if @rights.include?(name)
32:                 return @rights[name].allowed?(request.name, request.ip)
33:             elsif @rights.include?(namespace)
34:                 return @rights[namespace].allowed?(request.name, request.ip)
35:             else
36:                 return false
37:             end
38:         end

Does the file exist? Puppetmasterd does not require it, but puppetd does.

[Source]

    # File lib/puppet/network/authconfig.rb, line 42
42:         def exists?
43:             FileTest.exists?(@file)
44:         end

Read the configuration file.

[Source]

    # File lib/puppet/network/authconfig.rb, line 64
64:         def read
65:             return unless FileTest.exists?(@file)
66: 
67:             if @configstamp
68:                 if @configtimeout and @configstatted
69:                     if Time.now - @configstatted > @configtimeout
70:                         @configstatted = Time.now
71:                         tmp = File.stat(@file).ctime
72: 
73:                         if tmp == @configstamp
74:                             return
75:                         else
76:                             Puppet.notice "%s vs %s" % [tmp, @configstamp]
77:                         end
78:                     else
79:                         return
80:                     end
81:                 else    
82:                     Puppet.notice "%s and %s" % [@configtimeout, @configstatted]
83:                 end
84:             end
85: 
86:             parse()
87: 
88:             @configstamp = File.stat(@file).ctime
89:             @configstatted = Time.now
90:         end

[Validate]