Merge pull request #756 from Budibase/couchdb-security

Couchdb security
This commit is contained in:
Martin McKeaveney 2020-10-19 20:29:35 +01:00 committed by GitHub
commit 5217cce4fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -24,7 +24,7 @@ function replicate(local, remote) {
}) })
} }
async function replicateCouch({ instanceId, clientId, credentials }) { async function replicateCouch({ instanceId, clientId, session }) {
const databases = [`client_${clientId}`, "client_app_lookup", instanceId] const databases = [`client_${clientId}`, "client_app_lookup", instanceId]
const replications = databases.map(localDbName => { const replications = databases.map(localDbName => {
@ -32,8 +32,9 @@ async function replicateCouch({ instanceId, clientId, credentials }) {
const remoteDb = new CouchDB( const remoteDb = new CouchDB(
`${process.env.DEPLOYMENT_DB_URL}/${localDbName}`, `${process.env.DEPLOYMENT_DB_URL}/${localDbName}`,
{ {
auth: { fetch: function(url, opts) {
...credentials, opts.headers.set("Cookie", `${session};`)
return CouchDB.fetch(url, opts)
}, },
} }
) )
@ -118,7 +119,7 @@ async function deployApp({ instanceId, appId, clientId, deploymentId }) {
await replicateCouch({ await replicateCouch({
instanceId, instanceId,
clientId, clientId,
credentials: credentials.couchDbCreds, session: credentials.couchDbSession,
}) })
await updateDeploymentQuota(credentials.quota) await updateDeploymentQuota(credentials.quota)