如何使用sipers_map在hasura中正确映射以使`x-hasura-haseed opers'一个数组?
我有一个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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@Arjun Yelamanchili helped create a GitHub ticket at https://github.com/hasura/graphql -Engine/essugn/8402
这是一个临时解决方案,我最终得到了硬编码
x-hasura-howered opoles
,就像它更严格。
但是,我觉得这可能不是必需的,因为我们将定义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
likeIt 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.