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:
Rafael Taranto 2024-11-29 13:46:30 +00:00 committed by GitHub
commit 4794092aa1

View file

@ -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) =>