Skip to content

Commit 2296dca

Browse files
[DPE-7511] Fix the auth username pattern (#941)
* Fix auth username pattern Signed-off-by: Marcelo Henrique Neppel <[email protected]> * Fix another ocurrence of the pattern Signed-off-by: Marcelo Henrique Neppel <[email protected]> --------- Signed-off-by: Marcelo Henrique Neppel <[email protected]>
1 parent 3bd748a commit 2296dca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/charms/postgresql_k8s/v0/postgresql.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
# Increment this PATCH version before using `charmcraft publish-lib` or reset
3737
# to 0 if you are raising the major API version
38-
LIBPATCH = 54
38+
LIBPATCH = 55
3939

4040
# Groups to distinguish HBA access
4141
ACCESS_GROUP_IDENTITY = "identity_access"
@@ -751,7 +751,7 @@ def list_users_from_relation(self, current_host=False) -> Set[str]:
751751
"SELECT usename "
752752
"FROM pg_catalog.pg_user "
753753
"WHERE usename LIKE 'relation_id_%' OR usename LIKE 'relation-%' "
754-
"OR usename LIKE 'pgbouncer_auth_relation_id_%' OR usename LIKE '%_user_%_%';"
754+
"OR usename LIKE 'pgbouncer_auth_relation_%' OR usename LIKE '%_user_%_%';"
755755
)
756756
usernames = cursor.fetchall()
757757
return {username[0] for username in usernames}
@@ -830,7 +830,7 @@ def set_up_database(self) -> None:
830830
END IF;
831831
END LOOP;
832832
-- Remove users that don't exist anymore from the pg_hba file.
833-
FOR rec IN SELECT h.lines FROM pg_hba AS h LEFT JOIN relation_users AS r ON SPLIT_PART(h.lines, ' ', 3) = r.user WHERE r.user IS NULL AND (SPLIT_PART(h.lines, ' ', 3) LIKE 'relation_id_%' OR SPLIT_PART(h.lines, ' ', 3) LIKE 'pgbouncer_auth_relation_id_%' OR SPLIT_PART(h.lines, ' ', 3) LIKE '%_user_%_%')
833+
FOR rec IN SELECT h.lines FROM pg_hba AS h LEFT JOIN relation_users AS r ON SPLIT_PART(h.lines, ' ', 3) = r.user WHERE r.user IS NULL AND (SPLIT_PART(h.lines, ' ', 3) LIKE 'relation_id_%' OR SPLIT_PART(h.lines, ' ', 3) LIKE 'pgbouncer_auth_relation_%' OR SPLIT_PART(h.lines, ' ', 3) LIKE '%_user_%_%')
834834
LOOP
835835
DELETE FROM pg_hba WHERE lines = rec.lines;
836836
changes := changes + 1;

0 commit comments

Comments
 (0)