File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
web/pgadmin/utils/driver/psycopg3 Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 1717import secrets
1818import datetime
1919import asyncio
20- import copy
2120from collections import deque
21+ from pathlib import Path
2222import psycopg
2323from flask import g , current_app
2424from flask_babel import gettext
@@ -281,7 +281,6 @@ def connect(self, **kwargs):
281281 password , encpass , is_update_password = \
282282 self ._check_user_password (kwargs )
283283
284- passfile = kwargs ['passfile' ] if 'passfile' in kwargs else None
285284 tunnel_password = kwargs ['tunnel_password' ] if 'tunnel_password' in \
286285 kwargs else ''
287286
@@ -313,6 +312,17 @@ def connect(self, **kwargs):
313312 if is_error :
314313 return False , errmsg
315314
315+ # Retrieve password from passfile if one has not been set yet.
316+ passfile = Path (kwargs ['passfile' ]) if 'passfile' in kwargs else None
317+ if not password and passfile :
318+ try :
319+ password = passfile .read_text (encoding = 'utf-8' ).strip ()
320+ except (OSError , UnicodeDecodeError ) as e :
321+ return False , \
322+ _ (
323+ "Failed to read PassFile.\n Error: {0}" \
324+ ).format (str (e )
325+
316326 # If no password credential is found then connect request might
317327 # come from Query tool, ViewData grid, debugger etc tools.
318328 # we will check for pgpass file availability from connection manager
You can’t perform that action at this time.
0 commit comments