mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-12-22 15:13:42 -06:00
Add support for passing connection details as placeholders in the passexec command. #6794
Added a fix where electron app menu was not refreshing when node selection changed.
This commit is contained in:
parent
8876c4241f
commit
6810fa6ce6
@ -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.
|
||||
|
@ -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
|
||||
@ -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');
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,8 @@ class ServerManager(object):
|
||||
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
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user