1
votes

I have following scenario:

PouchDB sends user login info into application server:

POST /api/login
{user:'test', password:'test'}

Application server authenticates into Sync Gateway:

POST /sync_gateway/_sessions/

Obtained Cookie is being returned to angular application:

"SyncGatewaySession=89498ca5a159ff086a3cb1da2370eb36249936x5"

Question is how to configure PouchDB to authenticate with that cookie.

Ive tried setting cookie header but no luck.

Will appreciate any tips.

3
got any solution? i am facing same issue. appreciate for your help. - nic

3 Answers

0
votes

Authentication via direct usage of the REST API somehow does not work for subsequent requests (I faced the same problem). Please make use of the pouchdb-authentication plugin. It works perfectly fine. Here's the link: https://github.com/nolanlawson/pouchdb-authentication

0
votes

Try to set the "Authentication" header with encoded username and password combination instead of the cookie header. That should do the trick.

0
votes

Use the admin REST API to create a sessoin, then pass the session in another header than Cookie and use nginx to pass the custom header as cookie to sync gateway, like this:

proxy_set_header Cookie "$cookie_SGSession";