Skip to content

Commit ab9150b

Browse files
committed
Deprecate IP-based authentication
This will need to be made explicit in a future version, so it's good to get people to stop using it if possible.
1 parent 34b9c0b commit ab9150b

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

lib/puppet/network/authstore.rb

+10-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,16 @@ def ip?
150150

151151
# Does this declaration match the name/ip combo?
152152
def match?(name, ip)
153-
ip? ? pattern.include?(IPAddr.new(ip)) : matchname?(name)
153+
if ip?
154+
if pattern.include?(IPAddr.new(ip))
155+
Puppet.deprecation_warning "Authentication based on IP address is deprecated; please use certname-based rules instead"
156+
true
157+
else
158+
false
159+
end
160+
else
161+
matchname?(name)
162+
end
154163
end
155164

156165
# Set the pattern appropriately. Also sets the name and length.
@@ -212,7 +221,6 @@ def matchname?(name)
212221

213222
# Convert the name to a common pattern.
214223
def munge_name(name)
215-
# LAK:NOTE http://snurl.com/21zf8 [groups_google_com]
216224
# Change to name.downcase.split(".",-1).reverse for FQDN support
217225
name.downcase.split(".").reverse
218226
end

spec/integration/network/rest_authconfig_spec.rb

+22-3
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,31 @@ def add_regex_rule(regex, rule)
4444
end
4545

4646
def request(args = {})
47-
{ :ip => '10.1.1.1', :node => 'host.domain.com', :key => 'key', :authenticated => true }.each do |k,v|
48-
args[k] ||= v
49-
end
47+
args = {
48+
:key => 'key',
49+
:node => 'host.domain.com',
50+
:ip => '10.1.1.1',
51+
:authenticated => true
52+
}.merge(args)
5053
['test', :find, args[:key], args]
5154
end
5255

56+
it "should warn when matching against IP addresses" do
57+
add_rule("allow 10.1.1.1")
58+
59+
@auth.should allow(request)
60+
61+
@logs.should be_any {|log| log.level == :warning and log.message =~ /Authentication based on IP address is deprecated/}
62+
end
63+
64+
it "should not warn when matches against IP addresses fail" do
65+
add_rule("allow 10.1.1.2")
66+
67+
@auth.should_not allow(request)
68+
69+
@logs.should_not be_any {|log| log.level == :warning and log.message =~ /Authentication based on IP address is deprecated/}
70+
end
71+
5372
it "should support IPv4 address" do
5473
add_rule("allow 10.1.1.1")
5574

0 commit comments

Comments
 (0)