-
Notifications
You must be signed in to change notification settings - Fork 852
Read password from PassFile when connecting. #9810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,8 +17,8 @@ | |
| import secrets | ||
| import datetime | ||
| import asyncio | ||
| import copy | ||
| from collections import deque | ||
| from pathlib import Path | ||
| import psycopg | ||
| from flask import g, current_app | ||
| from flask_babel import gettext | ||
|
|
@@ -281,7 +281,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 '' | ||
|
|
||
|
|
@@ -313,6 +312,15 @@ def connect(self, **kwargs): | |
| if is_error: | ||
| return False, errmsg | ||
|
|
||
| # Retrieve password from passfile, if one has not been set yet. | ||
| passfile = Path(kwargs['passfile']) if 'passfile' in kwargs else None | ||
| if not password and passfile: | ||
| try: | ||
| password = passfile.read_text(encoding='utf-8').strip() | ||
|
||
| except (OSError, UnicodeDecodeError) as e: | ||
| error = _("Failed to read PassFile.\nError: {0}").format(str(e)) | ||
| return False, error | ||
|
|
||
| # 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 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.