Always verify that users have proper authorization to access and modify resources before performing any data operations. This prevents privilege escalation attacks and unauthorized data access.
Always verify that users have proper authorization to access and modify resources before performing any data operations. This prevents privilege escalation attacks and unauthorized data access.
Key principles:
Example implementation:
async update(tx, change: UpdateValue<typeof schema.tables.issue>) {
// First verify user can access the resource
await assertIsAdminOrCreator(tx, tx.query.issue, change.id);
// Then perform the operation
await tx.mutate.issue.update(change);
}
// In permissions schema
select: [
(authData, {exists}) =>
exists('issue', q => q.where(eb => canSeeIssue(authData, eb))),
]
This pattern prevents scenarios where users could perform operations on resources they cannot see due to permission changes, and ensures consistent security enforcement across all data access patterns.
Enter the URL of a public GitHub repository