【问题标题】:cochdb permissions roles always "not authorized"cochdb 权限角色始终“未授权”
【发布时间】:2018-06-25 13:04:11
【问题描述】:

我尝试使用 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 中看到权限。

当我现在尝试访问数据库时

获取http://myhost:1234/database/_all_docs

它返回:

{
    "error": "unauthorized",
    "reason": "You are not authorized to access this db."
}

【问题讨论】:

    标签: authentication permissions couchdb fauxton


    【解决方案1】:

    如果您使用的是 Postman,请在 Headers 中添加以下键值

    "Content-Type": "application/json",
      Accept: "application/json",
      Authorization: "Basic " + btoa("YOUR_ADMIN_USER:YOUR_PASSWORD")
    

    【讨论】:

      【解决方案2】:

      啊,我发现了错误,我正在使用邮递员进行测试,但我没有意识到凭据没有与请求一起发送 :-(

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-05-16
        • 1970-01-01
        • 2019-03-12
        • 2019-12-08
        • 2018-10-11
        • 1970-01-01
        • 1970-01-01
        • 2014-05-08
        相关资源
        最近更新 更多