Search code examples
google-chromegoogle-oauthpouchdbiriscouch

save chrome extension's data (idb) to iriscouch with google oAuth


Is it possible for a chrome extension to sync local database for each chrome user (pouchDB, indexedDB) over irisCouch, withoud any custom authentication service/server in the middle, just using google's logged in user (oAuth) ?

I'm trying to figure this out for days but I'm really stuck just to find out if it's possible.

I'm not sure if I'm heading in the right direction, but I imagined this kind of flow:

  1. create google identitiy, relax csp in manifest, add permission to my NAME.iriscouch.com in manifest
  2. enable CORS on iriscouch
  3. generate user's token authentication on irisCouch
  4. I will need per-user database for each chrome user to have unique data?

I can't seem to find tutorials on this matter, and I don't have the time to read 100 pages of documentation from various sources.


Solution

  • The weak link in your plan is going to be IrisCouch. I think I may have a claim to the shortest and most definitive guide to CouchDB authentication. You say you don't have much time, but you should probably read it. ;)

    Basically the problem you're going to run into is that IrisCouch (which is just CouchDB) doesn't have any APIs for creating users and giving them a database.

    You will need a separate service to make this work. I.e. you will need some kind of server-side process that takes the oAuth credentials, creates a user in IrisCouch (using admin credentials!), and then gives that user a private database.