Permissions (IAM): moderators and scoped grants #40
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature/permissions"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #29. Step 4 of the plan; the permission model that content moderation (#20) will use.
Roles: قاری (reader), موڈریٹر L2 (junior), سینئر موڈریٹر L1 (senior), ایڈمن. Changed with a dropdown on
/admin.Grants (admins give them to moderators on
/admin/user/<id>, linked as "اجازتیں" next to each moderator):The target is picked by pasting the poet, book or work's page link (e.g.
/p266,/p266/ghazal,/p266/ghazal/sh7870; full URLs work too). Grants can be revoked; demoting a moderator to reader or admin clears their grants; grant and revoke are in the audit log.One check:
can(user, action, content, target)inapi/src/permissions.ts. Admins can do everything, readers nothing; a moderator only what a grant covers (the work's poet, its book and every section above it are matched). Every moderation endpoint in #31/#32 will call it.Tested
npm test: 23 pass. On real content: a grant on Ghalib's غزل section allows editing a ghazal in it but not a Ghalib work outside it, not a delete, not poets, not Iqbal; a poet grant on Iqbal allows creating books; dictionary grants refused unless site-wide; unknown page links refused; moderators cannot manage grants; revoke and demotion take effect.🤖 Generated with Claude Code