Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions docs/en_US/server_dialog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ Use the fields in the *Advanced* tab to configure a connection:
command will be used as the SQL password. This may be useful when the password
should be generated as a transient authorization token instead of providing a
password when connecting in `PAM authentication <https://www.postgresql.org/docs/current/auth-pam.html>`_ scenarios.
You can pass server hostname, port and DB username to the password exec command as variable by providing placeholders
like ``%HOST%``, ``%PORT%`` and ``%USERNAME%`` which will be replace with the server connection information.
Example: ``/path/to/script --hostnmae %HOST% --port %PORT% --username %USERNAME%``
* Use the *Password exec expiration* field to specify a maximum age, in seconds,
of the password generated with a *Password exec command*. If not specified,
the password will not expire until your pgAdmin session does.
Expand Down
8 changes: 2 additions & 6 deletions web/pgadmin/browser/static/js/MainMenuFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ export default class MainMenuFactory {
return new MenuItem({type: 'separator', label, priority});
}

static refreshMainMenuItems(menu, menuItems) {
menu.setMenuItems(menuItems);
window.electronUI?.setMenus(MainMenuFactory.toElectron());
pgAdmin.Browser.Events.trigger('pgadmin:refresh-menu-item', pgAdmin.Browser.MainMenus);
}

static createMenuItem(options) {
return new MenuItem({...options, callback: () => {
// Some callbacks registered in 'callbacks' check and call specifiec callback function
Expand Down Expand Up @@ -128,6 +122,8 @@ export default class MainMenuFactory {
// set the context menu as well
pgAdmin.Browser.BrowserContextMenu = MainMenuFactory.getDynamicMenu('context', item, itemData, true);

window.electronUI?.setMenus(MainMenuFactory.toElectron());

pgAdmin.Browser.Events.trigger('pgadmin:refresh-app-menu');
}

Expand Down
3 changes: 2 additions & 1 deletion web/pgadmin/utils/driver/psycopg3/server_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def update(self, server):
self.db_res = server.db_res
self.name = server.name
self.passexec = \
PasswordExec(server.passexec_cmd, server.passexec_expiration) \
PasswordExec(server.passexec_cmd, server.host, server.port,
server.username, server.passexec_expiration) \
if server.passexec_cmd else None
self.service = server.service

Expand Down
8 changes: 6 additions & 2 deletions web/pgadmin/utils/passexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ class PasswordExec:

lock = Lock()

def __init__(self, cmd, expiration_seconds=None, timeout=60):
self.cmd = str(cmd)
def __init__(self, cmd, host, port, username, expiration_seconds=None,
timeout=60):
cmd = str(cmd).replace('%HOSTNAME%', host)
cmd = cmd.replace('%PORT%', str(port))
cmd = cmd.replace('%USERNAME%', username)
self.cmd = cmd
self.expiration_seconds = int(expiration_seconds) \
if expiration_seconds is not None else None
self.timeout = int(timeout)
Expand Down
Loading