1

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.

Vladimir Nani
  • 2,774
  • 6
  • 31
  • 52

3 Answers3

0

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

Haresh
  • 61
  • 8
  • Thanks. But there is incompatibility with Sync Gateway i am talking about post to /_sessions whereas sync gateway expects /dbname/_sessions – Vladimir Nani May 25 '16 at 10:26
0

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

Sarvesh Chitko
  • 158
  • 1
  • 9
0

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";
Reza Ghorbani
  • 2,396
  • 2
  • 28
  • 33