authentication - cochdb 权限角色始终“未授权”
问题描述
我尝试使用 CouchDB 进行用户/角色身份验证(基于会话),但是一旦我在数据库中输入角色,所有用户和角色都可以访问数据库 -> 未经授权。
获取会话:
发布 http://myhost:1234/ _session
它返回(userCtx 对象):
{
"ok": true,
"name": "some_user_name",
"roles": [
"developers"
]
}
然后我将角色添加到数据库中:
把 http://myhost:1234/database/ _security
{
"admins": {
"names": [],
"roles": []
},
"members": {
"names": [],
"roles": [
"developers"
]
}
}
它返回{"ok":true}
,我也可以在 fauxton 中看到权限。
当我现在尝试使用
它返回:
{
"error": "unauthorized",
"reason": "You are not authorized to access this db."
}
解决方案
如果您使用的是 Postman,请在标题中添加以下键值
"Content-Type": "application/json",
Accept: "application/json",
Authorization: "Basic " + btoa("YOUR_ADMIN_USER:YOUR_PASSWORD")
推荐阅读
- c++ - 如何在 C++ 中使用 SFML 和 Box2D 设置记分板
- python - python 请求或 urllib3 计时
- salesforce - 如何自动创建 Salesforce 增量 package.xml?
- python - 字符串值重复使用示例函数时
- command - 我正在尝试制作一个只能放置在某些块上的杠杆
- mpi - MPI如何为CPU核分配进程?
- python - 熊猫测试一列是否是另一列的子集?(即B列包含A列)
- python - 查找networkx中每对节点之间的边
- reactjs - 如何构建 next.js 文件并上传到 linux 共享主机
- python - 使用 BeautifulSoup 加载带有下拉框的页面