RBAC
Manage access control easily using role-based permissions.
Demo
Usage
SaaSkit integrates with Better Auth to provide a flexible role-based access control (RBAC) system. It allows you to control what users can access based on their assigned role.
By default, the system includes two roles:
- user – limited permissions
- superadmin – full permissions
and two resources with up to six permissions.
- user:
createlistset-rolebanimpersonatedeleteset-password - session:
listrevokedelete
To create a superadmin user, sign in normally first. Then go to your database and change the user's role to superadmin.
Permission
To create a new permission, edit the lib/permission.ts file.
For example, let’s create a permission that allows access to the admin dashboard.
Here:
statementdefines available permissions.- Each role specifies which actions it is allowed to perform.
Role
To create a new role, edit the same lib/permission.ts file.
After creating the role, make sure to include it in the Role type.
Access
You can conditionally show UI or protect pages based on permissions.