Skip to content

Commit

Permalink
Deprecate IP-based authentication
Browse files Browse the repository at this point in the history
This will need to be made explicit in a future version, so it's good to
get people to stop using it if possible.
  • Loading branch information
nicklewis committed Jun 27, 2012
1 parent 34b9c0b commit ab9150b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
12 changes: 10 additions & 2 deletions lib/puppet/network/authstore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,16 @@ def ip?

# Does this declaration match the name/ip combo?
def match?(name, ip)
ip? ? pattern.include?(IPAddr.new(ip)) : matchname?(name)
if ip?
if pattern.include?(IPAddr.new(ip))
Puppet.deprecation_warning "Authentication based on IP address is deprecated; please use certname-based rules instead"
true
else
false
end
else
matchname?(name)
end
end

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

# Convert the name to a common pattern.
def munge_name(name)
# LAK:NOTE http://snurl.com/21zf8 [groups_google_com]
# Change to name.downcase.split(".",-1).reverse for FQDN support
name.downcase.split(".").reverse
end
Expand Down
25 changes: 22 additions & 3 deletions spec/integration/network/rest_authconfig_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,31 @@ def add_regex_rule(regex, rule)
end

def request(args = {})
{ :ip => '10.1.1.1', :node => 'host.domain.com', :key => 'key', :authenticated => true }.each do |k,v|
args[k] ||= v
end
args = {
:key => 'key',
:node => 'host.domain.com',
:ip => '10.1.1.1',
:authenticated => true
}.merge(args)
['test', :find, args[:key], args]
end

it "should warn when matching against IP addresses" do
add_rule("allow 10.1.1.1")

@auth.should allow(request)

@logs.should be_any {|log| log.level == :warning and log.message =~ /Authentication based on IP address is deprecated/}
end

it "should not warn when matches against IP addresses fail" do
add_rule("allow 10.1.1.2")

@auth.should_not allow(request)

@logs.should_not be_any {|log| log.level == :warning and log.message =~ /Authentication based on IP address is deprecated/}
end

it "should support IPv4 address" do
add_rule("allow 10.1.1.1")

Expand Down

0 comments on commit ab9150b

Please sign in to comment.