postgresql - Hasura继承角色权限不一致

标签 postgresql graphql hasura

我试图在 Hasura 中定义两个角色:

  • role_1:在 my_table 中,可以更新:column_Acolumn_B
  • role_2:在my_table中,可以更新:column_C

我希望最终用户能够在不指定角色的情况下更新 column_Acolumn_Bcolumn_C,因此我将它们合并到一个继承的角色:user

将元数据上传到 Hasura 时收到以下错误:

{
  "internal": [
    {
      "reason": "Could not inherit permission for the role 'user' for the entity: 'update permission, table: my_table, source: 'my_source''",
      "name": "user",
      "type": "inherited role permission inconsistency",
      "entity": {
        "permission_type": "update",
        "source": "my_source",
        "table": "my_table"
      }
    }
  ],
  "path": "$.args",
  "error": "cannot continue due to inconsistent metadata",
  "code": "unexpected"
}

我的元数据中的 my_table 权限:

"update_permissions": [
  {
    "role": "role_1",
    "permission": {
      "filter": ...(check if I can update column_A and column_B)
      },
      "columns": [
        "column_A",
        "column_B"
      ]
    }
  },
  {
    "role": "role_2",
    "permission": {
      "filter": ...(a different check if I can update column_C)
      },
      "columns": [
        "column_C"
      ]
    }
  }
],

继承角色配置:

"inherited_roles": [
    {
      "role_name": "user",
      "role_set": [
        "role_1",
        "role_2"
      ]
    }
  ]

如果我在更新权限/角色中包含所有三列,则效果很好。但这不是我想要的🙁

最佳答案

(感谢 Hasura Discorf 上的 jmart 的回答):

据我了解该功能,它是一系列检查,而不是检查组合。

因此,它会查看用户是否有权从其有权访问的第一个角色中选择列 ABC,如果没有,则检查它是否有权通过任何其他角色进行访问。

如果没有一个角色包含所有请求的列,则会被视为冲突,因为它们存在冲突的权限规则。

关于postgresql - Hasura继承角色权限不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72145781/

相关文章:

SQL UNION 问题

sql - 在 Postgresql 中,如何从一列中有 M 个不同值的表中获取未知的记录数?

node.js - 如何更新我的 gatsby 及其依赖项

azure-ad-b2c - AAD B2C : Output a nested JSON object in a JWT for Hasura

postgresql - 如何使用 Postgraphile 或替代方案在 Postgres 中实现复杂的基于权限的数据访问

postgresql - 如何在 Hasura 上进行 postgres 数据备份

sql - 使用窗口函数计算每个事件行在给定间隔内事件的先前发生次数

macos - -bash : initdb: command not found

amazon-web-services - AWS AppSync WebUI 非常慢

reactjs - Graphql:Typescript + Jest + Relay + Jest 似乎无法集成在一起