summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-06-28 14:42:04 +0200
committerJames Turnbull <james@lovedthanlost.net>2009-07-07 16:19:39 +1000
commitea66cf6b9a5de1dd784dfed8995babf90225f8a0 (patch)
tree678a1a2ba846b1092131f2957cba479ee4a11566 /lib
parent1e83aadc749aea9d52281d4f4041f6144a7229c7 (diff)
downloadpuppet-ea66cf6b9a5de1dd784dfed8995babf90225f8a0.tar.gz
puppet-ea66cf6b9a5de1dd784dfed8995babf90225f8a0.tar.xz
puppet-ea66cf6b9a5de1dd784dfed8995babf90225f8a0.zip
Fix #2348 - Allow authstore (and REST auth) to match allow/deny against opaque strings
This patch removes the limitation of allow/deny which were only matching ip addresses or hostname (or pattern of). It makes sure any kind of string can be matched (by strict equality) while still keeping the old behaviour. Opaque strings can only contains: alphanumeric characters, - _ and @. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib')
-rwxr-xr-xlib/puppet/network/authstore.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/puppet/network/authstore.rb b/lib/puppet/network/authstore.rb
index 6f7a7df25..306e1ba8a 100755
--- a/lib/puppet/network/authstore.rb
+++ b/lib/puppet/network/authstore.rb
@@ -249,7 +249,7 @@ module Puppet
# Does the name match our pattern?
def matchname?(name)
- name = munge_name(name)
+ name = munge_name(name) unless @name == :opaque
return true if self.pattern == name
# If it's an exact match, then just return false, since the
@@ -324,10 +324,17 @@ module Puppet
end
begin
@pattern = IPAddr.new(value)
+ @name = :ip
rescue ArgumentError => detail
- raise AuthStoreError, "Invalid pattern %s" % value
+ # so nothing matched, let's match as an opaque value
+ # some sanity checks first
+ unless value =~ /^[a-zA-Z0-9][-a-zA-Z0-9_.@]*$/
+ raise AuthStoreError, "Invalid pattern %s" % value
+ end
+ @pattern = [value]
+ @length = nil # force an exact match
+ @name = :opaque
end
- @name = :ip
end
end
end