如何使用Parse Server设置类级别权限?

时间:2016-03-15 18:35:56

标签: parse-platform parse-server

我正在将应用程序从Parse.com(托管)迁移到自托管的* Parse Server实现(https://github.com/ParsePlatform/parse-server)。

我的应用程序在很大程度上依赖于类级别权限,因此,例如,所有用户都可以使用公钥读取全局设置,但不使用主密钥进行编辑或删除。

在Parse.com上,这些权限可在仪表板中配置,但开源Parse Server没有仪表板。也许有一些方法可以使用云代码来做到这一点?

*我使用App Engine的托管虚拟机环境,虽然我不确定是否相关。

2 个答案:

答案 0 :(得分:2)

我在mongodb数据存储区中找到了_SCHEMA表,它包含了我正在寻找的CLP。显然,这是他们存储的地方,他们与Parse.com的其他数据一起迁移。我已确认更新这些值会影响数据访问权限

答案 1 :(得分:1)

使用restful api

https://parseplatform.github.io/docs/parse-server/guide/#class-level-permissions

// PUT http://localhost:1337/schemas/:className
// Set the X-Parse-Application-Id and X-Parse-Master-Key header
// body:
{
  classLevelPermissions:
  {
    "find": {
      "requiresAuthentication": true,
      "role:admin": true
    },
    "get": {
      "requireAuthentication": true,
      "role:admin": true
    },
    "create": { "role:admin": true },
    "update": { "role:admin": true },
    "delete": { "role:admin": true },
  }
}