Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions web/pgadmin/utils/driver/psycopg3/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import secrets
import datetime
import asyncio
import copy
from collections import deque
import psycopg
from flask import g, current_app
Expand Down Expand Up @@ -281,7 +280,6 @@ def connect(self, **kwargs):
password, encpass, is_update_password = \
self._check_user_password(kwargs)

passfile = kwargs['passfile'] if 'passfile' in kwargs else None
tunnel_password = kwargs['tunnel_password'] if 'tunnel_password' in \
kwargs else ''

Expand Down Expand Up @@ -313,14 +311,22 @@ def connect(self, **kwargs):
if is_error:
return False, errmsg

# If no password credential is found then connect request might
# come from Query tool, ViewData grid, debugger etc tools.
# we will check for pgpass file availability from connection manager
# if it's present then we will use it
if not password and not encpass and not passfile:
passfile = manager.get_connection_param_value('passfile')
if manager.passexec:
password = manager.passexec.get()
# If no password credential is found then connect request might come
# from Query tool, ViewData grid, debugger, etc. In that case, fall
# back to using the password returned from manager.passexec.
passfile = manager.get_connection_param_value('passfile')
if not password and not encpass and not passfile and manager.passexec:
password = manager.passexec.get()

# create_connection_string() automatically picks up the passfile from
# connection parameters. Warn if that differs from the passfile kwarg.
passfile_kwarg = kwargs.get('passfile', None)
if passfile_kwarg and passfile_kwarg != passfile:
current_app.logger.warning(
"Using the first of two specified passfiles: {!r}, {!r}".format(
passfile, passfile_kwarg
)
)

try:
database = self.db
Expand Down