Merge pull request #1757 from RafaelTaranto/backport/hide-secrets-from-request
LAM-1243 fix: correctly hide secret fields from GQL results
This commit is contained in:
commit
4794092aa1
1 changed files with 11 additions and 8 deletions
|
|
@ -100,16 +100,19 @@ function loadAccounts (schemaVersion) {
|
||||||
.then(_.compose(_.defaultTo({}), _.get('data.accounts')))
|
.then(_.compose(_.defaultTo({}), _.get('data.accounts')))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hideSecretFields (accounts) {
|
||||||
|
return _.flow(
|
||||||
|
_.filter(path => !_.isEmpty(_.get(path, accounts))),
|
||||||
|
_.reduce(
|
||||||
|
(accounts, path) => _.assoc(path, PASSWORD_FILLED, accounts),
|
||||||
|
accounts
|
||||||
|
)
|
||||||
|
)(SECRET_FIELDS)
|
||||||
|
}
|
||||||
|
|
||||||
function showAccounts (schemaVersion) {
|
function showAccounts (schemaVersion) {
|
||||||
return loadAccounts(schemaVersion)
|
return loadAccounts(schemaVersion)
|
||||||
.then(accounts => {
|
.then(hideSecretFields)
|
||||||
const filledSecretPaths = _.compact(_.map(path => {
|
|
||||||
if (!_.isEmpty(_.get(path, accounts))) {
|
|
||||||
return path
|
|
||||||
}
|
|
||||||
}, SECRET_FIELDS))
|
|
||||||
return _.compose(_.map(path => _.assoc(path, PASSWORD_FILLED), filledSecretPaths))(accounts)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const insertConfigRow = (dbOrTx, data) =>
|
const insertConfigRow = (dbOrTx, data) =>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue