Skip to content

Commit 7403d8e

Browse files
authored
Add custom users to pg_hba filter (#1040)
1 parent 66cf5c8 commit 7403d8e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/charm.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,15 +2359,21 @@ def relations_user_databases_map(self) -> dict:
23592359
logger.warning(f"Failed to list access groups: {e}")
23602360
return {USER: "all", REPLICATION_USER: "all", REWIND_USER: "all"}
23612361
user_database_map = {}
2362-
for user in self.postgresql.list_users_from_relation(
2363-
current_host=self.is_connectivity_enabled
2364-
):
2365-
databases = ",".join(
2362+
for user in self.postgresql.list_users(current_host=self.is_connectivity_enabled):
2363+
if user in (
2364+
"backup",
2365+
"monitoring",
2366+
"operator",
2367+
"postgres",
2368+
"replication",
2369+
"rewind",
2370+
):
2371+
continue
2372+
if databases := ",".join(
23662373
self.postgresql.list_accessible_databases_for_user(
23672374
user, current_host=self.is_connectivity_enabled
23682375
)
2369-
)
2370-
if databases:
2376+
):
23712377
user_database_map[user] = databases
23722378
else:
23732379
logger.debug(f"User {user} has no databases to connect to")

0 commit comments

Comments
 (0)