1) Fix issue where SSH tunnel connection using password is failing, it's regression of Master Password. Fixes #4320

2) Fix some more issues related to SSH Tunnel(By: Akshay Joshi)
This commit is contained in:
Aditya Toshniwal 2019-06-05 12:07:24 +05:30 committed by Akshay Joshi
parent 13704a4f34
commit a588c2994d
5 changed files with 33 additions and 9 deletions

View File

@ -11,6 +11,7 @@ notes for it.
.. toctree::
:maxdepth: 1
release_notes_4_9
release_notes_4_8
release_notes_4_7
release_notes_4_6

View File

@ -0,0 +1,16 @@
***********
Version 4.9
***********
Release date: 2019-06-27
This release contains a number of bug fixes and new features since the release of pgAdmin4 4.8.
New features
************
Bug fixes
*********
| `Bug #4320 <https://redmine.postgresql.org/issues/4320>`_ - Fix issue where SSH tunnel connection using password is failing, it's regression of Master Password.

View File

@ -918,19 +918,19 @@ define('pgadmin.node.server', [
id: 'tunnel_host', label: gettext('Tunnel host'), type: 'text', group: gettext('SSH Tunnel'),
mode: ['properties', 'edit', 'create'], deps: ['use_ssh_tunnel'],
disabled: function(model) {
return !model.get('use_ssh_tunnel');
return !model.get('use_ssh_tunnel') || model.get('connected');
},
},{
id: 'tunnel_port', label: gettext('Tunnel port'), type: 'int', group: gettext('SSH Tunnel'),
mode: ['properties', 'edit', 'create'], deps: ['use_ssh_tunnel'], max: 65535,
disabled: function(model) {
return !model.get('use_ssh_tunnel');
return !model.get('use_ssh_tunnel') || model.get('connected');
},
},{
id: 'tunnel_username', label: gettext('Username'), type: 'text', group: gettext('SSH Tunnel'),
mode: ['properties', 'edit', 'create'], deps: ['use_ssh_tunnel'],
disabled: function(model) {
return !model.get('use_ssh_tunnel');
return !model.get('use_ssh_tunnel') || model.get('connected');
},
},{
id: 'tunnel_authentication', label: gettext('Authentication'), type: 'switch',
@ -939,7 +939,7 @@ define('pgadmin.node.server', [
'offText': gettext('Password'), 'size': 'mini', width: '90'},
deps: ['use_ssh_tunnel'],
disabled: function(model) {
return !model.get('use_ssh_tunnel');
return !model.get('use_ssh_tunnel') || model.get('connected');
},
}, {
id: 'tunnel_identity_file', label: gettext('Identity file'), type: 'text',
@ -963,7 +963,7 @@ define('pgadmin.node.server', [
group: gettext('SSH Tunnel'), control: 'input', mode: ['create'],
deps: ['use_ssh_tunnel'],
disabled: function(model) {
return !model.get('use_ssh_tunnel');
return !model.get('use_ssh_tunnel') || model.get('connected');
},
}, {
id: 'save_tunnel_password', controlLabel: gettext('Save password?'),

View File

@ -14,7 +14,7 @@
<div class="save-password-div input-group py-2">
<div class="w-100">
<input id="save_tunnel_password" name="save_tunnel_password" type="checkbox"
{% if not config.ALLOW_SAVE_PASSWORD %}disabled{% endif %}
{% if not config.ALLOW_SAVE_TUNNEL_PASSWORD %}disabled{% endif %}
>
<label for="save_tunnel_password" class="ml-1">Save Password</label>
</div>

View File

@ -87,9 +87,12 @@ class ServerManager(object):
if config.SUPPORT_SSH_TUNNEL:
self.use_ssh_tunnel = server.use_ssh_tunnel
self.tunnel_host = server.tunnel_host
self.tunnel_port = server.tunnel_port
self.tunnel_port = \
22 if server.tunnel_port is None else server.tunnel_port
self.tunnel_username = server.tunnel_username
self.tunnel_authentication = server.tunnel_authentication
self.tunnel_authentication = 0 \
if server.tunnel_authentication is None \
else server.tunnel_authentication
self.tunnel_identity_file = server.tunnel_identity_file
self.tunnel_password = server.tunnel_password
else:
@ -469,8 +472,12 @@ WHERE db.oid = {0}""".format(did))
return False, gettext("Unauthorized request.")
if tunnel_password is not None and tunnel_password != '':
crypt_key_present, crypt_key = get_crypt_key()
if not crypt_key_present:
raise CryptKeyMissing()
try:
tunnel_password = decrypt(tunnel_password, user.password)
tunnel_password = decrypt(tunnel_password, crypt_key)
# Handling of non ascii password (Python2)
if hasattr(str, 'decode'):
tunnel_password = \