Couchdb使用用户名和密码同步访问 [英] Couchdb sync access with userid and password

查看:661
本文介绍了Couchdb使用用户名和密码同步访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在虚拟linux机器上运行的couchdb。该数据库已启用cors和设置。我已经向数据库添加了管理员用户和
密码。我也将require_valid_user设置为true。
我正在尝试使用下面的代码在线同步沙发上的pouchdb和benchdb。如果我只是传递数据库的地址
(下面的1),则会出现一个对话框,要求输入用户名和密码。同步在此示例中有效。
如果尝试在URL中传递用户名和密码(如下面的2所示),则会收到同步错误,并显示消息
getCheckpoint被拒绝。
对于我在做错事情或应采取的其他方法的任何建议,将不胜感激。

I have a couchdb running on a virtual linux machine. This db has cors enabled and setup. I have added an admin user and password to the db. I also have require_valid_user set to true. I am trying to sync a pouchdb in a web page with the couchdb online with the code below. If I just pass the address for the db (1 below), I get a dialog box asking for a user and password. The sync works in this example. If I try to pass the user name and password in the URL (as in 2 below), I get a sync error and the message "getCheckpoint rejected with ". Any suggestions on what I am doing wrong or another approach I should taking with this would be greatly appreciated.

谢谢

PS我可以使用用户名和密码浏览到URL。

P.S. I am able to browse to the URL with the user and password.

var remoteCouch = "http://192.168.1.7:5984/mydb";  //1
//var remoteCouch = "http://userid:password@192.168.1.7:5984/mydb"; //2
sync();

function sync() {
  var opts = {live: true};
  db.sync(remoteCouch,opts,syncError);
}


推荐答案

我遇到了同样的问题尝试同步到cloudant.com上的ouchDB的完全相同的错误消息。对我来说,解决方案是在远程服务器的URL中使用https://而不是http://。
URL的格式应为:

I had the same problem with the exact same error message trying to sync to a couchDB on cloudant.com. For me, the solution was to use https:// instead of http:// in the URL of the remote server. The format of the URL should be:

https://< api_key>:< key_passwd> @<用户名> ; .cloudant.com /< db_name>

因此,尽管我没有本地安装的数据库对此进行测试,但我怀疑您的错误源于这样的事实:在您提供凭据时,沙发将请求重定向到安全连接(场景1)。在方案2中,没有重定向发生。

So although I do not have a locally installed DB to test this, I suspect your error stems from the fact that couch redirects the request to a secure connection when you provide your credentials (scenario 1). While in scenario 2 no redirect occurs.

这篇关于Couchdb使用用户名和密码同步访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆