4

I'm running a docker container with admin secret. In the below image, you can see the roles under the permissions window. enter image description here

For category table, I set public role for SELECT option and there is no restriction for that role to access any query.

enter image description here

But my problem is I can't access the query using public role, hasura engine ask admin-secret. see the below image. How can I access this API without giving admin credentials? enter image description here

Akash D
  • 780
  • 2
  • 11
  • 27

2 Answers2

2

Relevant docs: https://hasura.io/docs/1.0/graphql/manual/auth/authentication/unauthenticated-access.html#unauthenticated-public-access

If you are using webhook-based authentication, "for unauthenticated access, you can return a 200 status response with your defined unauthenticated role, e.g: { "x-hasura-role": "<anonymous-role>" }."

If you are using jwt-based authentication, "you can use the env variable HASURA_GRAPHQL_UNAUTHORIZED_ROLE or --unauthorized-role flag to set a role for unauthenticated (non-logged in) users."

The unauthenticated role can be called anything, in your case it would be "public"

avimoondra
  • 886
  • 5
  • 9
  • Do i have to pass HASURA_GRAPHQL_UNAUTHORIZED_ROLE this in request header with value anonymous. I have set up this role and made public api. Now, i wanted to call that api from Apollo. My Hasura instance is set up with JTW mode. But some api i wanted to access from apollo in vue app as public to which I have also set up HASURA_GRAPHQL_UNAUTHORIZED_ROLE role – Wikki Nov 13 '21 at 15:59
0

you have to set the HASURA_GRAPHQL_UNAUTHORIZED_ROLE to the unauthorized role name in the env variables of the cloud console sample config

in my case, it's called public, then subsequent request should use the following header

x-hasura-default-role: public without any need for JWT or Admin.

mal-sh
  • 1