Skip to content

Commit 98234b0

Browse files
committed
Read password from PassFile when connecting.
Use PassFile to retrieve a password when one is not retrieved by other means. The PassFile setting was already passed to connect() but was never read.
1 parent d8a078a commit 98234b0

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

web/pgadmin/utils/driver/psycopg3/connection.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import asyncio
2020
import copy
2121
from collections import deque
22+
from pathlib import Path
2223
import psycopg
2324
from flask import g, current_app
2425
from flask_babel import gettext
@@ -281,7 +282,6 @@ def connect(self, **kwargs):
281282
password, encpass, is_update_password = \
282283
self._check_user_password(kwargs)
283284

284-
passfile = kwargs['passfile'] if 'passfile' in kwargs else None
285285
tunnel_password = kwargs['tunnel_password'] if 'tunnel_password' in \
286286
kwargs else ''
287287

@@ -313,6 +313,11 @@ def connect(self, **kwargs):
313313
if is_error:
314314
return False, errmsg
315315

316+
# Retrieve password from passfile if one has not been set yet.
317+
passfile = Path(kwargs['passfile']) if 'passfile' in kwargs else None
318+
if not password and passfile:
319+
password = passfile.read_text()
320+
316321
# If no password credential is found then connect request might
317322
# come from Query tool, ViewData grid, debugger etc tools.
318323
# we will check for pgpass file availability from connection manager

0 commit comments

Comments
 (0)