triplit
triplit copied to clipboard
[Feature] "default" permission option
Right now it can become redundant to define the same permissions for every operation, and makes permissions a bit difficult to track and manage at times.
For example..
authenticated: {
read: {
filter: [
or([
["userId", "=", "$token.sub"],
["organization.members.userId", "=", "$token.sub"]
])
]
},
insert: {
filter: [
or([
["userId", "=", "$token.sub"],
["organization.members.userId", "=", "$token.sub"]
])
]
},
update: {
filter: [
or([
["userId", "=", "$token.sub"],
["organization.members.userId", "=", "$token.sub"]
])
]
},
postUpdate: {
filter: [
or([
["userId", "=", "$token.sub"],
["organization.members.userId", "=", "$token.sub"]
])
]
}
}
This would become a lot more manageable if I could just define it once as "default" or something similar. Could be as simple as if they want to read, check "read" key if it exists for permissions, if it doesn't, check "default" key if it exists.
Simplified:
authenticated: {
default: {
filter: [
or([
["userId", "=", "$token.sub"],
["organization.members.userId", "=", "$token.sub"]
])
]
}
}