用户无法在 CouchDB 中_users访问自己的文档



我在Windows上使用CouchDB 3.1.0时遇到问题。我已经安装了它,在安装过程中创建了一个管理员用户(admin:admin(,然后创建了一个用户,如文档所述:

$ curl -X PUT http://admin:admin@localhost:5984/_users/org.couchdb.user:jan 
>      -H "Accept: application/json" 
>      -H "Content-Type: application/json" 
>      -d '{"name": "jan", "password": "apple", "roles": [], "type": "user"}'
{"ok":true,"id":"org.couchdb.user:jan","rev":"1-fd5a90118f51fb895d594f2fdfa9b12f"}

好。现在让我获取用户文档:

$ curl -X GET http://jan:apple@localhost:5984/_users/org.couchdb.user:jan
{"error":"forbidden","reason":"You are not allowed to access this db."}

我做错了什么?我错过了什么?

当然,它确实在CouchDB 2.3中工作。

谢谢。

不幸的是,CouchDB 3.x 的文档已经过时了。截至今天,安全文档中的身份验证数据库部分指出:

用户只能访问(GET /_users/org.couchdb.user:Jan(或修改 (PUT /_users/org.couchdb.user:Jan( 他们拥有的文件

但是,它没有说明默认情况下用户无权访问_users数据库中的任何文档。

为了允许访问,必须首先在设置中将users_db_security_editable标志更改为 true,然后清除_users安全对象中的members -> roles列表。默认情况下,此列表中包含_admin。或者,您可以向用户添加角色,然后将该角色添加到members -> roles

请注意,这将允许用户对其用户文档进行读写访问。

有一个开放的 Github 问题来修改文档。

其他来源:

https://github.com/apache/couchdb/issues/2881

https://github.com/apache/couchdb/issues/2730

相关内容

最新更新