簡體   English   中英

MongoDB、ACL和用戶的Restheart

[英]Restheart for MongoDB, ACL and users

我有一個帶有 atlas 示例數據庫的 MongoDB 實例,我正在嘗試在其上配置 Restheart。
我在 restheart 配置了 mongoRealmAuthenticator 和 MongoAclAuthorizer,在 restheart 數據庫中配置了 ACL 和 USERS collections,以及以下 mongo-mounts:

- what: /sample_weatherdata  
  where: /sample_weatherdata

Users 集合有 admin 用戶和一個名為 sample_weatherdata 且具有用戶角色的用戶。 ACL 集合具有以下 ACL。

 { "_id": "userCanGetOwnCollection", "roles": [ "user" ], "predicate": "method(GET) and path-template('/{userid}') and equals(@user.userid, ${userid})", "priority": 100, "_etag": ObjectId("62322951a40a5c34cad71769") }

但是,當我嘗試使用 curl(curl -k -u sample_weatherdata:secret -X GET https://xxxxx:4443/sample_weatherdata?page=1)從 sample_weatherdata 數據庫獲取信息時,我在 restheart 上遇到了錯誤日志:

21:01:22.702 [XNIO-1 task-1] DEBUG o.r.s.authorizers.FileAclAuthorizer - 角色用戶、權限(角色=[用戶]、謂詞=方法(GET)和路徑模板('/{userid }') and equals(@user.userid, ${userid}) and qparams-contain(page) and qparams-blacklist(filter, sort) ), resolve false

21:01:22.716 [XNIO-1 task-1] DEBUG o.r.s.authorizers.MongoAclAuthorizer - 角色用戶,權限 id BsonString{value='userCanGetOwnCollection'},解析錯誤

21:01:22.718 [XNIO-1 task-1] INFO org.restheart.handlers.RequestLogger - GET https://xxxxxxx:4443/sample_weatherdata?page=1 from /10.100.200.100:55555 => status=403 elapsed= 26ms contentLength=0 username=sample_weatherdata roles=[user]

知道我是否遺漏了什么或如何配置 ACL 以允許查詢嗎?

如果您使用默認的身份驗證器,即mongoRealmAuthenticator用戶的正確 id 屬性是@user._id

所以你的許可應該是:

{
        "_id" : "userCanGetOwnCollection",
        "roles" : [ "user" ],
        "predicate" : "method(GET) and path-template('/{userid}') and equals(@user._id, ${userid})",
        "priority" : 100
}

在示例acl.json 中,您有:

注意:用戶的 id 是 @user.userid 與 fileRealmAuthenticator 和 @user._id 與 mongoRealmAuthenticator

我是 RESTHeart 的主要提交者,鑒於現在mongoRealmAuthenticator是默認的身份驗證器,我剛剛更新了示例 acl.json 和相關文檔以使用@user._id

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM