Custom Authentication with 2 Sync Gateway


I’m trying add Custom Authentication. I use 2 instances of Sync-Gateway behind an Nginx. So how can we manage Session with 2 instances of Sync-Gateway?
I’m using custom authentication which is achieved by calling the “/_session” endpoint. This then returns a cookie that logs me in for the first Sync-Gateway. If I now want to synchronize the second Sync-Gateway too, I make a call to “/_session” which overrides the first cookie.

Is there any way to create a global Session?

@youssefl , When you say 2 instances, do you mean 2 sync gateways? You can use nginx to create user session . If sync gateway talks to same bucket of one couchbase server, both the instances of sync gateway will share the user session. You do not need to create 2 different session for each instance. You could use nginx url to create session and use that session for any CRUD operation for both the instances of sync gateways.

@sridevi.saragadam Thanks for response. we need to tolks to 2 Couchbase Server. So how can we manage authentication for more than one database?


If you’re using 2 separate CB buckets/SG databases, they’re completely independent systems and user-information is not shared between them.

Can you describe your use-case a bit more to explain why you have 2 buckets and databases? Typically this is something that can be supported with 1 bucket by creating a “type” field in documents, or a document ID prefix to segment the data.

My question is about replication. In ourcCase we need to use 3 replications of couchbase Server with 2 Sync Gateway. So how can we manage authentication with those 3 replication of couchbase server?