I using firebase auth, and i want to create API tokens for my users (role user) with role 'API'. How can I implement this?
Firebase tokens expire in 1 hour. It's not good for me.
I鈥檓 thinking about how to save tokens in the database and compare their _exists before the request. How to configure Hasura to work on authorization and without authorization?
You can configure an 'unauthenticated' role and then define permissions for that role: https://docs.hasura.io/1.0/graphql/manual/auth/authentication/unauthenticated-access.html.
Yes ! This is my solution.
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: "anonymous"
And permissions
{
"_and":[
{
"_exists":{
"_table":{
"name":"user",
"schema":"public"
},
"_where":{
"id":{
"_eq":"X-Hasura-User-Id"
}
}
}
},
{
"_exists":{
"_table":{
"name":"token",
"schema":"public"
},
"_where":{
"_and":[
{
"id":{
"_eq":"X-Hasura-Token-Id"
}
},
{
"user_id":{
"_eq":"X-Hasura-User-Id"
}
}
]
}
}
}
]
}