From 635fb50b580de65087cc24726823090b1ce500c9 Mon Sep 17 00:00:00 2001 From: Daniel Schreiber Date: Fri, 7 Jul 2023 11:51:20 +0200 Subject: [PATCH] Fix: allow multiple users/databases in postgresql_access resources PostgreSQL pg_hba.conf allows to specify multiple databases and users in one entry. They are seperated by comma. --- CHANGELOG.md | 2 ++ libraries/access.rb | 2 +- test/cookbooks/test/recipes/access.rb | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b9d893a9..6ca3390c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in the last 3 major versions of the postg ## Unreleased +- Allow to configure multiple databases and users in one `pg_hba.conf` entry + ## 11.5.1 - *2023-06-26* - Fix typo in documentation of `postgresql_extension` resource diff --git a/libraries/access.rb b/libraries/access.rb index 2f88245e4..1a05df184 100644 --- a/libraries/access.rb +++ b/libraries/access.rb @@ -70,7 +70,7 @@ class PgHbaFile attr_reader :entries - SPLIT_REGEX = %r{^(((?local)\s+(?[\w\-_]+)\s+(?[\w\d\-_.$]+))|((?!local)(?\w+)\s+(?[\w\-_]+)\s+(?[\w\d\-_.$]+)\s+(?
[\w\-.:\/]+)))\s+(?[\w-]+)(?(?:\s+#{AUTH_OPTION_REGEX})*)(?:\s*)(?#\s*.*)?$}.freeze + SPLIT_REGEX = %r{^(((?local)\s+(?[\w\-_,]+)\s+(?[\w\d\-_.$,]+))|((?!local)(?\w+)\s+(?[\w\-_,]+)\s+(?[\w\d\-_.$,]+)\s+(?
[\w\-.:\/]+)))\s+(?[\w-]+)(?(?:\s+#{AUTH_OPTION_REGEX})*)(?:\s*)(?#\s*.*)?$}.freeze private_constant :SPLIT_REGEX def initialize diff --git a/test/cookbooks/test/recipes/access.rb b/test/cookbooks/test/recipes/access.rb index 631cea2c3..cd7cf04d0 100644 --- a/test/cookbooks/test/recipes/access.rb +++ b/test/cookbooks/test/recipes/access.rb @@ -128,3 +128,11 @@ ldapbasedn: '"dc=example, dc=net"', ldapsearchattribute: 'uid' end + +postgresql_access 'access with multiple databases' do + type 'host' + database 'foo,bar' + user 'john,doe' + address '127.0.0.1/32' + auth_method 'md5' +end