diff --git a/ROLE_BASED_ACCESS_CONTROL.md b/ROLE_BASED_ACCESS_CONTROL.md new file mode 100644 index 0000000..265446f --- /dev/null +++ b/ROLE_BASED_ACCESS_CONTROL.md @@ -0,0 +1,93 @@ +# Ske_Signage Role-Based Access Control Implementation + +## Summary of Changes + +This document outlines the modifications made to implement proper role-based access control in the Ske_Signage project, ensuring that both 'admin' and 'sadmin' roles have appropriate access to user management functions while maintaining the 'sadmin' role as the highest privilege level. + +## Modified Files + +### 1. `/app/routes/admin.py` +**Changes made:** +- **create_user function (lines ~75-85)**: + - Changed restriction from completely preventing sadmin creation to allowing only sadmin users to create other sadmin users + - Regular admins can now create admin and user roles, but not sadmin + +- **edit_user function (lines ~460-470)**: + - Changed from completely preventing sadmin editing to allowing sadmin users to edit other sadmin users + - Regular admins cannot modify sadmin users or assign sadmin role + +- **delete_user function (lines ~108-130)**: + - Changed decorator from `@super_admin_required` to `@admin_required` + - Added protection so only sadmin users can delete other sadmin users + - Regular admins can delete admin and user roles, but not sadmin + +### 2. `/app/templates/admin/index.html` +**Changes made:** +- **User row clickability (line ~164)**: + - Modified logic to allow sadmin users to edit other sadmin users + - `user.role != 'sadmin' or current_user.is_super_admin` + +- **Edit action visibility (lines ~190-196)**: + - Updated to show edit option for sadmin users when current user is also sadmin + - Shows "Protected" badge only for sadmin users when current user is not sadmin + +- **Edit form expandable rows (line ~202)**: + - Modified condition to allow sadmin editing by other sadmin users + +- **Role selection in edit form (lines ~224-230)**: + - Added sadmin option only visible to super admin users + - `{% if current_user.is_super_admin %}