Row Permissions with not always existing session variable #10794
-
|
Is it strictly required to send all session variables, that are used in row permissions?
Is there any way to allow for missing session variables and check for null in the row permission setting? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Yes, Hasura requires all session variables referenced in permissions to be present in the request. There is no built-in "if exists" or null-check for session variables themselves in the permission rules. A couple of workarounds: 1. Always send the variable, even if empty The cleanest approach is to have your auth webhook always return 2. Use a default role without feature-based permissions If some users genuinely never have features, consider using a separate Hasura role for them (e.g. 3. Restructure the permission rule If your {
"_or": [
{"feature": {"name": {"_in": "x-hasura-allowed-features"}}},
{"is_public": {"_eq": true}}
]
}And you want it to work when There have been feature requests for default values on session variables, but nothing has landed yet. For now, making the webhook always emit the variable (even as an empty value) is the most pragmatic path. |
Beta Was this translation helpful? Give feedback.
Yes, Hasura requires all session variables referenced in permissions to be present in the request. There is no built-in "if exists" or null-check for session variables themselves in the permission rules.
A couple of workarounds:
1. Always send the variable, even if empty
The cleanest approach is to have your auth webhook always return
x-hasura-allowed-featureswith an empty array[]when the user has no features. I know you mentioned the webhook does not know what variables might be expected, but this is the intended pattern -- the auth layer should be aware of the session variables the permission system requires.2. Use a default role without feature-based permissions
If some users genui…