For a phonegap app that I’m working on, I have developed an app server that is responsible for handling two-factor authentication instead of the traditional username/password combination. For 1st time users, I want it to also create user account documents on couchbase server that will not contain username and password, but will contain other authentication data. Then when the user logs in again, I want the app server to check couchbase server for the user account and if it’s valid, use sync gateway’s admin port to create a session as specified in the “Custom (Indirect) Authentication” documentation. During the sync gateway session, the user can CRUD documents.
I’ve read almost all of the documentation for couchbase lite REST API, sync gateway, and couchbase server. But I need some guidance on how I should setup sync gateway with couchbase server so that my app server can create user account documents while allowing authenticated users to CRUD documents through sync gateway. Here are two approaches that I’m considering:
- Use bucket shadowing so that the app server can create user account documents directly on couchbase server
- Have the app server use the admin port to sync gateway to create user account documents
I’m open to other architectural ideas as well.