cookie based auth for deployment
This commit is contained in:
parent
3679416322
commit
a06c504619
|
@ -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 databases = [`client_${clientId}`, "client_app_lookup", instanceId]
|
||||||
|
|
||||||
const replications = databases.map(localDbName => {
|
const replications = databases.map(localDbName => {
|
||||||
|
@ -24,10 +24,16 @@ 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)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
// {
|
||||||
|
// auth: {
|
||||||
|
// ...credentials,
|
||||||
|
// },
|
||||||
|
// }
|
||||||
)
|
)
|
||||||
|
|
||||||
return replicate(localDb, remoteDb)
|
return replicate(localDb, remoteDb)
|
||||||
|
@ -92,7 +98,7 @@ exports.deployApp = async function(ctx) {
|
||||||
await replicateCouch({
|
await replicateCouch({
|
||||||
instanceId: ctx.user.instanceId,
|
instanceId: ctx.user.instanceId,
|
||||||
clientId,
|
clientId,
|
||||||
credentials: credentials.couchDbCreds,
|
session: credentials.couchDbSession,
|
||||||
})
|
})
|
||||||
|
|
||||||
await updateDeploymentQuota(credentials.quota)
|
await updateDeploymentQuota(credentials.quota)
|
||||||
|
|
Loading…
Reference in New Issue