Update: I think I solved this. But I’m confused. Please see and confirm note at the end.
Thanks. Very well explained. This confirms what I thought about roles. But here is the role that does not work. I’m pasting its FQL tab contents.
{
ref: Role("loggedInUser"),
ts: 1597726876959400,
name: "loggedInUser",
membership: [
{
resource: Collection("users")
}
],
privileges: [
{
resource: Collection("Task"),
actions: {
read: true,
write: true,
create: true,
delete: true
}
},
{
resource: Index("allTasks"),
actions: {
unrestricted_read: false,
read: true
}
}
]
}
Now, here is how I pass back the secret that I receive from Login call after success. I put this in GraphQL Header pane.
{
"authorization": "Bearer fnADziABYoACBw-Zb9iF5YEByvdUu5DD6U0HOsg-"
}
After that, when I issue a GraphQL query:
query ListAllTasks {
allTasks {
data {
_id
description
}
}
}
I get this:
{
"errors": [
{
"message": "Insufficient privileges to perform the action.",
"extensions": {
"code": "permission denied"
}
}
]
}
Is it some kind of limitation of GraphQL API of FaunaDB that it can’t use a token returned by Login?
Update: I think I solved it. I had to add resource “Collections” to the Role with a “Read” permission.
FQL dump for insert:
{
resource: Ref("collections"),
actions: {
read: true,
write: false,
create: false,
delete: false,
history_read: false,
history_write: false
}
}
How is this different from permission on Resource Collection Tasks with all operations allowed which was already there? Shouldn’t that permission to read collections be implicit with the earlier resource statement for Tasks collection?