-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: rework sys_admin authorizations #249
base: release/2.1.1
Are you sure you want to change the base?
Conversation
This change fixes user access control for "sys_admin" users to have access to all projects. It also introduces a get_user_groups utility function to determine a user's role and refactors project access logic to use this function.
This change fix several bugs to the admin interface, focusing on improved security and user management. Specifically, it refines the permissions for managing user accounts, adds visual distinctions for superuser roles
Reviewer's Guide by SourceryThis pull request refines the system administrator authorizations and user interface, addressing issues where new system administrators were getting stuck on the welcome page and preventing system administrators from editing superuser profiles. Sequence diagram for user modification authorization flowsequenceDiagram
participant A as Administrator
participant S as System
participant T as Target User
A->>S: Request to modify user
S->>S: Check modification mode
alt Mode is create
S->>S: Skip user checks
S-->>A: Allow modification
else Other modes
S->>S: Get current user role
S->>S: Get target user role
alt Target is superuser & Current is not superuser
S-->>A: Deny modification (403)
else Self-modification for admin roles
S-->>A: Deny self deletion/deactivation (403)
else Valid modification
S-->>A: Allow modification
end
end
Class diagram for user role and permissions structureclassDiagram
class User {
+is_superuser: boolean
+is_active: boolean
+username: string
+date_joined: datetime
}
class UserGroup {
+name: string
}
class Project {
+name: string
+slug: string
+insert_date: datetime
}
User "*" -- "*" Project: belongs to
User "*" -- "1" UserGroup: has role
note for UserGroup "Available roles:\n- superuser\n- sys_admin\n- auditor\n- penetration_tester"
note for User "New restrictions:\n- Only superuser can modify superuser\n- Admins cannot delete themselves"
State diagram for user access controlstateDiagram-v2
[*] --> CheckUserRole
CheckUserRole --> SuperUser: is_superuser
CheckUserRole --> SysAdmin: in sys_admin group
CheckUserRole --> Auditor: in auditor group
CheckUserRole --> PenTester: in penetration_tester group
SuperUser --> FullAccess: Can modify all users
SysAdmin --> RestrictedAccess: Cannot modify superusers
Auditor --> LimitedAccess
PenTester --> LimitedAccess
state RestrictedAccess {
[*] --> CanModifyRegularUsers
CanModifyRegularUsers --> CannotModifySuperUsers
CannotModifySuperUsers --> CannotModifySelf
}
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @psyray - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🟢 Security: all looks good
- 🟡 Testing: 1 issue found
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@AnonymousWP |
Fix #241
This change introduces several fixes to the
sys_admin
role.Better check the project list to prevent new sys admins to be stucked on Welcome page
Refines the permissions of the user administration actions to prevent
superuser
profile edition bysys_admin
, only superuser can edit superuserClarify user roles in the administrator interface.
sys_admin
creation