Skip to content

Commit 56069d7

Browse files
committed
add eric feedback
1 parent 245a258 commit 56069d7

File tree

1 file changed

+19
-7
lines changed
  • superset-frontend/src/views/CRUD/data/database/DatabaseModal

1 file changed

+19
-7
lines changed

superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import {
6363
ExtraJson,
6464
} from 'src/views/CRUD/data/database/types';
6565
import Loading from 'src/components/Loading';
66-
import { omit } from 'lodash';
66+
import { pick } from 'lodash';
6767
import ExtraOptions from './ExtraOptions';
6868
import SqlAlchemyForm from './SqlAlchemyForm';
6969
import DatabaseConnectionForm from './DatabaseConnectionForm';
@@ -373,29 +373,41 @@ export function dbReducer(
373373
[action.payload.name]: action.payload.value,
374374
},
375375
};
376-
case ActionType.setSSHTunnelLoginMethod:
376+
case ActionType.setSSHTunnelLoginMethod: {
377+
let ssh_tunnel = {};
378+
if (trimmedState?.ssh_tunnel) {
379+
// remove any attributes that are considered sensitive
380+
ssh_tunnel = pick(trimmedState.ssh_tunnel, [
381+
'id',
382+
'server_address',
383+
'server_port',
384+
'username',
385+
]);
386+
}
377387
if (action.payload.login_method === AuthType.privateKey) {
378388
return {
379389
...trimmedState,
380390
ssh_tunnel: {
381-
...omit(trimmedState?.ssh_tunnel, ['password']),
391+
private_key: trimmedState?.ssh_tunnel?.private_key,
392+
private_key_password:
393+
trimmedState?.ssh_tunnel?.private_key_password,
394+
...ssh_tunnel,
382395
},
383396
};
384397
}
385398
if (action.payload.login_method === AuthType.password) {
386399
return {
387400
...trimmedState,
388401
ssh_tunnel: {
389-
...omit(trimmedState?.ssh_tunnel, [
390-
'private_key',
391-
'private_key_password',
392-
]),
402+
password: trimmedState?.ssh_tunnel?.password,
403+
...ssh_tunnel,
393404
},
394405
};
395406
}
396407
return {
397408
...trimmedState,
398409
};
410+
}
399411
case ActionType.removeSSHTunnelConfig:
400412
return {
401413
...trimmedState,

0 commit comments

Comments
 (0)