简体   繁体   English

使用非服务器管理员用户身份验证将PouchDb复制到CouchDb

[英]PouchDb to CouchDb replication with non server admin user authentication

I'm trying to replicate a local PouchDb database to a remote CouchDb database. 我正在尝试将本地PouchDb数据库复制到远程CouchDb数据库。 Before ending the "Admin party" everything worked perfect. 在结束“管理方”之前,一切正常。 But when I configured the admin user I needed admin auth. 但是,当我配置管理员用户时,我需要管理员身份验证。 So after reading A LOT I figured out how to authenticate. 因此,在阅读了很多文章之后,我想出了如何进行身份验证。

remoteCouch = new PouchDB('http://127.0.0.1:5984/database_name', {ajax: {headers: {'Cookie': cookie}}})
PouchDB.replicate(_db, remoteCouch)

If I use the server admin credentials when getting the cookie then I can replicate. 如果在获取Cookie时使用服务器管理员凭据,则可以复制。 But what I really want is to enable a regular admin user, that has permissions on a particular DB, to replicate on that DB. 但是,我真正想要的是使对特定数据库具有权限的普通管理员用户能够在该数据库上进行复制。

If I log in with user "X" and on the target database I have a _security document with user "X" on the admins list, it gives me an auth error saying I'm not a server admin. 如果我使用用户“ X”登录并在目标数据库上,我在admins列表上有一个_security文档,用户“ X”,它给我一个auth错误,表明我不是服务器管理员。

I've read about the Replicator database en the userCtx. 我已经阅读了有关userCtx的Replicator数据库的信息。 But when I replicate using PouchDb nothing happens on the Replicator database. 但是,当我使用PouchDb复制时,Replicator数据库上没有任何反应。

https://gist.github.com/fdmanana/832610 https://gist.github.com/fdmanana/832610

Is there any way I can allow replication for non-server-admin user "X"? 有什么方法可以允许非服务器管理员用户“ X”进行复制? User "X" needs your help! 用户“ X”需要您的帮助!

I would say you have done everything right. 我会说你做对了所有事情。 The only thing that seems wrong is that you send the authentication cookie to the local database instead of to the remote one. 似乎唯一的错误是您将身份验证cookie发送到本地数据库而不是远程数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM