如何使用sipers_map在hasura中正确映射以使`x-hasura-haseed opers'一个数组?

发布于 2025-01-21 15:34:05 字数 1412 浏览 4 评论 0原文

我有一个JWT令牌,看起来

{
  "aud": "xx",
  "iss": "http://xx.com/adfs/services/trust",
  "iat": 1649956864,
  "exp": 1649960464,
  "apptype": "xx",
  "appid": "dcf6c0d8-7f3c-4904-a0c9-852c92c7624f",
  "authmethod": "http://xx",
  "auth_time": "2022-04-14T17:21:04.095Z",
  "ver": "1.0"
}

我试图将appid映射到x-hasura-howered opoles字段作为数组的项目,该项目是使用sips> apple> sippors_map < /代码>在Hasura中。

HASURA_GRAPHQL_JWT_SECRET: '{"jwk_url":"xx","claims_map":{"x-hasura-allowed-roles":{"path":"$.appid"},"x-hasura-default-role":{"path":"$.appid"}}}'

在内部注意此部分:

"x-hasura-allowed-roles":{"path":"$.appid"}

查询时我会遇到此错误

无效的X-Hasura允许功能;应该是角色列表:解析[]失败,预期数组,但遇到字符串

是有道理的,因为x-hasura-hashed oper需要是一个数组。

首先尝试(失败),

如果我更改为

"x-hasura-allowed-roles":[{"path":"$.appid"}]

启动hasura时,我会收到错误

致命错误: - 环境变量hasura_graphql_jwt_secret:$ ['sapers_map'] [0]中的错误

致命错误: - 环境变量hasura_graphql_jwt_secret :

"x-hasura-allowed-roles":{"path":["$.appid"]}

致命错误: - 环境变量hasura_graphql_jwt_secret:$ ['sapers_map']中的错误。路径:解析文本失败,预期字符串,但遇到的数组

如何正确映射以制作x-hasura-walleed oper field field 字段数组?谢谢

I have a JWT token which looks like

{
  "aud": "xx",
  "iss": "http://xx.com/adfs/services/trust",
  "iat": 1649956864,
  "exp": 1649960464,
  "apptype": "xx",
  "appid": "dcf6c0d8-7f3c-4904-a0c9-852c92c7624f",
  "authmethod": "http://xx",
  "auth_time": "2022-04-14T17:21:04.095Z",
  "ver": "1.0"
}

I am trying to map appid into x-hasura-allowed-roles field as an item of an array by using claims_map in Hasura.

HASURA_GRAPHQL_JWT_SECRET: '{"jwk_url":"xx","claims_map":{"x-hasura-allowed-roles":{"path":"$.appid"},"x-hasura-default-role":{"path":"$.appid"}}}'

Note this part inside:

"x-hasura-allowed-roles":{"path":"$.appid"}

I will get this error when I query

invalid x-hasura-allowed-roles; should be a list of roles: parsing [] failed, expected Array, but encountered String

which makes sense, because x-hasura-allowed-roles needs to be an array.

First Try (Failed)

If I change to

"x-hasura-allowed-roles":[{"path":"$.appid"}]

When I start Hasura, I will get the error

Fatal Error:- Environment variable HASURA_GRAPHQL_JWT_SECRET: Error in $['claims_map'][0]: parsing String failed, expected String, but encountered Object

Second Try (Failed)

"x-hasura-allowed-roles":{"path":["$.appid"]}

Fatal Error:- Environment variable HASURA_GRAPHQL_JWT_SECRET: Error in $['claims_map'].path: parsing Text failed, expected String, but encountered Array

How to map correctly to make x-hasura-allowed-roles field an array? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩物 2025-01-28 15:34:05

@Arjun Yelamanchili helped create a GitHub ticket at https://github.com/hasura/graphql -Engine/essugn/8402


这是一个临时解决方案,我最终得到了硬编码x-hasura-howered opoles,就像

HASURA_GRAPHQL_JWT_SECRET: '{"jwk_url":"xx","claims_map":{"x-hasura-allowed-roles":["dcf6c0d8-7f3c-4904-a0c9-852c92c7624f"],"x-hasura-default-role":{"path":"$.appid"}}}'

它更严格。

但是,我觉得这可能不是必需的,因为我们将定义Hasura UI中的每个Appid权限。另外,我需要更新hasura_graphql_jwt_secret每次我上板上新应用时。

@Arjun Yelamanchili helped create a GitHub ticket at https://github.com/hasura/graphql-engine/issues/8402


Here is a temp solution, I ended up with hardcoding x-hasura-allowed-roles like

HASURA_GRAPHQL_JWT_SECRET: '{"jwk_url":"xx","claims_map":{"x-hasura-allowed-roles":["dcf6c0d8-7f3c-4904-a0c9-852c92c7624f"],"x-hasura-default-role":{"path":"$.appid"}}}'

It is more strict.

However, I feel it might not be necessary, as we will define each appid permissions in Hasura UI. Also, I need update HASURA_GRAPHQL_JWT_SECRET each time when I onboard a new app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文