graphql - 如何访问 hasura 中的公共(public) api

标签 graphql hasura

我正在使用 admin secret 运行一个 docker 容器。在下图中,您可以在权限窗口下看到角色。 enter image description here

对于 category 表,我为 SELECT 选项设置了 public 角色,并且该角色没有访问任何查询的限制。

enter image description here

但我的问题是我无法使用public 角色访问查询,hasura 引擎询问admin-secret。见下图。 如何在不提供管理员凭据的情况下访问此 API? enter image description here

最佳答案

相关文档:https://hasura.io/docs/1.0/graphql/manual/auth/authentication/unauthenticated-access.html#unauthenticated-public-access

如果您使用基于 webhook 的身份验证,“对于未经身份验证的访问,您可以使用您定义的未经身份验证的角色返回 200 状态响应,例如:{ "x-hasura-role": "<anonymous-role>" }。”

如果您使用基于 jwt 的身份验证,“您可以使用环境变量 HASURA_GRAPHQL_UNAUTHORIZED_ROLE--unauthorized-role 标志为未经身份验证(未登录)的用户设置角色。”

未经身份验证的角色可以被称为任何东西,在您的情况下它将是“public”

关于graphql - 如何访问 hasura 中的公共(public) api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62670895/

相关文章:

graphql - graphql 模式循环引用是反模式吗?

node.js - 聚合函数返回 null GraphQL

docker - 如何在一个 Istio 服务网格中托管多个应用程序?

reactjs - 使用 Create React App with Relay 的最简单方法是什么?

graphql - 在 GraphQL 上传递数组

GraphQL 服务器中的授权

graphql - Hasura 查询的工作方式类似于 SQL 内连接

postgresql - 普通人表与教师和学生的特定表或单独的表?

postgresql - 将 hasura 与 Google Cloud Run 和 Google Cloud SQL 结合使用