cookie based auth for deployment
This commit is contained in:
parent
5db3c03ee9
commit
cdf82cf479
|
@ -16,7 +16,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 replications = databases.map(localDbName => {
|
||||
|
@ -24,10 +24,16 @@ async function replicateCouch({ instanceId, clientId, credentials }) {
|
|||
const remoteDb = new CouchDB(
|
||||
`${process.env.DEPLOYMENT_DB_URL}/${localDbName}`,
|
||||
{
|
||||
auth: {
|
||||
...credentials,
|
||||
fetch: function(url, opts) {
|
||||
opts.headers.set("Cookie", `${session};`)
|
||||
return CouchDB.fetch(url, opts)
|
||||
},
|
||||
}
|
||||
// {
|
||||
// auth: {
|
||||
// ...credentials,
|
||||
// },
|
||||
// }
|
||||
)
|
||||
|
||||
return replicate(localDb, remoteDb)
|
||||
|
@ -92,7 +98,7 @@ exports.deployApp = async function(ctx) {
|
|||
await replicateCouch({
|
||||
instanceId: ctx.user.instanceId,
|
||||
clientId,
|
||||
credentials: credentials.couchDbCreds,
|
||||
session: credentials.couchDbSession,
|
||||
})
|
||||
|
||||
await updateDeploymentQuota(credentials.quota)
|
||||
|
|
Loading…
Reference in New Issue