I'm setting up a Hasura server on top of an existing Postgres database. The schema uses JSONB a lot, and all entities are modelled like this:
EntityName
-----------
id: String
resource: JSONB
In my current case, I have the entity Appointment
. I want to create a Permission that one user only has select access to Appointments where it is a participant.
Appointment.resource
is modelled like this:
{
// ... some other fields ...
"participant": [
{
"actor": {
"reference": "a826ade6bcbf" // this is X-Hasura-User-Id
},
}
]
}
Which lead me to the following "Row select permissions" (writing it on the web console, if it makes a difference):
{
"resource": {
"_contains": {
"participant": [
{
"actor": {
"reference": "X-Hasura-User-Id"
}
}
]
}
}
}
The exported metadata for the table looks like this:
{
"version": 2,
"tables": [
{
"table": {
"schema": "public",
"name": "appointment"
},
"select_permissions": [
{
"role": "patient",
"permission": {
"columns": [
"id",
"resource",
],
"filter": {
"resource": {
"_contains": {
"participant": [
{
"actor": {
"reference": "X-Hasura-User-Id",
}
}
]
}
}
}
}
}
]
},
],
}
Thing is, if I try said rule on GraphiQL with the proper headers, I get an empty response. But if I change the rule to "reference": "a826ade6bcbf"
(a String literal), I get the expected response (only Appointments matching the filter).
It seems like X-Hasura-User-Id
is not being substituted on the Permission.
Am I doing something wrong? Is this feature supported?
Are there other options for authorization? Changing the current database schema is not a viable solution.