Roles and Permissions
The Role and Permission system in bPass provides fine-grained access control to manage what users can and cannot do within the application. This system is built on top of the Laravel Spatie Permission package and provides a flexible, hierarchical permission structure.
Overview
The role and permission system consists of:
- Roles: Named collections of permissions that can be assigned to users
- Permissions: Individual capabilities that grant access to specific features or actions
- Permission Groups: Organized categories of related permissions
- Default Roles: Automatically assigned roles for new users
Role Management
Viewing Roles
Navigate to Settings → Roles to view all available roles in your system. The role list displays:
- Role Name: The display name of the role
- Guard Name: The authentication guard (typically 'sanctum')
- Default Status: Whether this role is automatically assigned to new users
- Creation/Update Dates: When the role was created and last modified
- Permission Count: Number of permissions assigned to the role
Role Details
Each role card shows: - Role Icon: Visual identifier with colored gradient background - Role Metadata: Name, guard, and default status - Action Buttons: Edit and Delete options - Expandable Permissions: Click to view all assigned permissions
Creating a New Role
- Access Role Creation
- Navigate to Settings → Roles
-
Click the "New Role" button
-
Fill Role Information
- Role Name: Enter a descriptive name for the role
-
Is Default: Check this option if you want this role automatically assigned to new users > Note: Only one role should be marked as default at a time
-
Assign Permissions
- Select individual permissions or entire permission groups
- Use category checkboxes to select/deselect all permissions in a group
-
Individual permissions can be toggled independently
-
Save the Role
- Click Save to create the role
- The system will validate permissions and create the role
Editing Roles
- Access Role Editor
- From the role list, click the Edit button (pencil icon)
-
Or click on the role name
-
Modify Role Properties
- Update the role name if needed
- Change default status
-
Add or remove permissions
-
Permission Management
- Add Permissions: Check additional permission boxes
- Remove Permissions: Uncheck permission boxes
-
Group Selection: Use category headers to manage permission groups
-
Save Changes
- Click Save to apply changes
- All users with this role will immediately receive updated permissions
Deleting Roles
- Access Delete Option
-
From the role list, click the Delete button (trash icon)
-
Confirm Deletion
- Confirm the deletion in the popup dialog
-
Warning: This action cannot be undone
-
Restrictions
- Default roles cannot be deleted
- Roles assigned to users should be carefully considered before deletion
Permission System
Permission Structure
Permissions are organized into logical groups for better management:
Core Permission Groups
- User Management
show user: View user listingscreate user: Create new usersupdate user: Modify user information-
delete user: Remove users from system -
Role Management
show role: View roles and permissionscreate role: Create new rolesupdate role: Modify existing roles-
delete role: Delete roles -
Vault Management
show vault: View vault entriescreate vault: Create new vault entriesupdate vault: Modify vault entries-
delete vault: Delete vault entries -
Folder Management
show folder: View folderscreate folder: Create new foldersupdate folder: Modify folders-
delete folder: Delete folders -
Import/Export
import-vault: Import vault data-
export-vault: Export vault data -
Settings
general-settings: Manage application settings
Permission Hierarchy
The permission system supports hierarchical access:
- Administrative Permissions: Full system access
- Management Permissions: Resource-specific management
- User Permissions: Basic user functionality
- Read-Only Permissions: View-only access
Permission Assignment
Individual Assignment
- Select specific permissions for granular control
- Mix and match permissions from different groups
- Fine-tune access based on role requirements
Group Assignment
- Select entire permission groups for broad access
- Use intermediate state when some (but not all) permissions are selected
- Quickly assign related permissions together
Default Role System
First User Registration
When the very first user registers in the system: - They are automatically assigned the "Super Admin" role - This ensures system administration capabilities are available
Subsequent User Registration
For all other user registrations: - Users receive the role marked as "Default" - Only one role should be marked as default - If no default role exists, users get no initial role
Changing Default Roles
- Edit the desired role
- Check the "Is Default" option
- Ensure other roles have this option unchecked
- Save the changes
Best Practices
Role Design
- Principle of Least Privilege: Grant only necessary permissions
- Role-Based Access: Create roles based on job functions
- Clear Naming: Use descriptive role names
- Regular Review: Periodically audit role permissions
Permission Management
- Group Related Permissions: Use permission groups for easier management
- Document Changes: Keep track of permission modifications
- Test Thoroughly: Verify permission changes work as expected
- Backup Roles: Export role configurations before major changes
Security Considerations
- Protect Admin Roles: Limit super admin role assignments
- Default Role Security: Ensure default roles have appropriate minimal permissions
- Regular Audits: Review user role assignments periodically
- Permission Validation: Test permission restrictions regularly
Troubleshooting
Common Issues
Users Cannot Access Features
- Check Role Assignment: Verify user has appropriate role
- Verify Permissions: Ensure role has required permissions
- Clear Cache: Clear application cache if using cached permissions
Permission Changes Not Taking Effect
- Logout/Login: Users may need to re-authenticate
- Clear Session: Clear user sessions
- Check Middleware: Verify permission middleware is applied
Default Role Issues
- Multiple Defaults: Ensure only one role is marked as default
- No Default Role: Create and mark a role as default for new users
- Default Role Permissions: Verify default role has appropriate permissions
Error Messages
"Permission Denied"
- User lacks required permission for the action
- Check user's role and role's permissions
"Role Cannot Be Deleted"
- Default roles cannot be deleted
- Remove default status first, then delete
"Permission Not Found"
- Permission may have been removed or renamed
- Update role permissions accordingly
Technical Details
Database Structure
- Roles Table: Stores role information
- Permissions Table: Stores permission definitions
- Role_has_permissions: Links roles to permissions
- Model_has_roles: Links users to roles
API Endpoints
GET /roles: List all rolesGET /permissions: List all permissions (with grouping)POST /role: Create new rolePUT /role/{id}: Update existing roleDELETE /role/{id}: Delete role
Frontend Components
- RoleList.vue: Displays role listing with expandable permissions
- RoleForm.vue: Creates and edits roles
- PermissionField.vue: Manages permission selection with group support
This role and permission system provides the foundation for secure, scalable access control in your bPass installation.