-
Notifications
You must be signed in to change notification settings - Fork 15
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
Admins are now forbidden from promoting users to Super Admin. #440
Open
JohnServo24
wants to merge
24
commits into
klaudsol:staging
Choose a base branch
from
JohnServo24:patch-admin-vulnerabilities
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
bc4cf97
Merge pull request #439 from klaudsol/staging
JohnServo24 aa5a95e
Typo
JohnServo24 6ade52b
Can now check if user has super admin capabilities
JohnServo24 1b87beb
Admins are now forbidden to create superadmins
JohnServo24 ea62091
Patched up editing
JohnServo24 d310a4a
Add comment
JohnServo24 7625fae
Filtered out superadmins for admins on frontend
JohnServo24 00246bb
Added migrations
JohnServo24 aa2cb76
Typo
JohnServo24 57b741f
Added base function
JohnServo24 fefc664
SSR'ed groups
JohnServo24 8568534
Filtered out super admin
JohnServo24 fd6d96f
Hardcoded super admin checkbox
JohnServo24 0e04f00
getServerSideProps now returns usergroups and userdata on [id]
JohnServo24 918c4bf
SSR'ed edit page
JohnServo24 237ad27
Deleted groups
JohnServo24 2afb11d
Secured POST
JohnServo24 ca034cc
Removed promise all for assertUserCan
JohnServo24 286b17d
Added comments
JohnServo24 53ddc1e
Added missing await
JohnServo24 612ecf0
Superadmin hidden on frontend
JohnServo24 70e39cb
Changed assignToGroup
JohnServo24 f2543b2
Removed comments
JohnServo24 dd4ec0c
Hid superadmin checkbox again
JohnServo24 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
db/migrations/20230518141105_insert_promote_to_super_admin_capability.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"up": [ | ||
"INSERT INTO capabilities (name, description, is_system_supplied) VALUES", | ||
"('promote_to_super_admin', \"Can create/promote a user to Super Admin\", true)" | ||
], | ||
"down":[ | ||
"DELETE FROM capabilities WHERE name = 'promote_to_super_admin' AND is_system_supplied = true" | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
db/migrations/20230518141330_connect_promote_super_admin_capability_to_super_admin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"up": [ | ||
"INSERT INTO group_capabilities (group_id, capabilities_id) VALUES", | ||
"(1, (SELECT id FROM capabilities WHERE name = 'promote_to_super_admin' AND is_system_supplied = true))" | ||
], | ||
"down":[ | ||
"DELETE FROM group_capabilities WHERE group_id IN = 1", | ||
"AND capabilities_id = (SELECT id FROM capabilities WHERE name = 'promote_to_super_admin' AND is_system_supplied = true);" | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
db/migrations/20230522085940_disconnect_promote_super_admin_capability_to_super_admin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"up": [ | ||
"DELETE FROM group_capabilities WHERE group_id = 1 ", | ||
"AND capabilities_id = (SELECT id FROM capabilities WHERE name = 'promote_to_super_admin' AND is_system_supplied = true);" | ||
], | ||
"down": [ | ||
"INSERT INTO group_capabilities (group_id, capabilities_id) VALUES", | ||
"(1, (SELECT id FROM capabilities WHERE name = 'promote_to_super_admin' AND is_system_supplied = true))" | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
db/migrations/20230522090030_delete_promote_to_super_admin_capability.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"up": [ | ||
"DELETE FROM capabilities WHERE name = 'promote_to_super_admin' AND is_system_supplied = true" | ||
], | ||
"down": [ | ||
"INSERT INTO capabilities (name, description, is_system_supplied) VALUES", | ||
"('promote_to_super_admin', \"Can create/promote a user to Super Admin\", true)" | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
db/migrations/20230522090410_insert_assign_to_group_capability.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"up": [ | ||
"INSERT INTO capabilities (name, description, is_system_supplied) VALUES", | ||
"('assign_to_group', \"Can assign a user to a group\", true)" | ||
], | ||
"down":[ | ||
"DELETE FROM capabilities WHERE name = 'assign_to_group' AND is_system_supplied = true" | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
db/migrations/20230522090520_connect_assign_to_group_capability_to_super_admin.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"up": [ | ||
"INSERT INTO group_capabilities (group_id, capabilities_id, params1) VALUES ", | ||
"(1, (SELECT id FROM capabilities WHERE name = 'assign_to_group' AND is_system_supplied = true), 1)" | ||
], | ||
"down":[ | ||
"DELETE FROM group_capabilities WHERE group_id IN = 1 ", | ||
"AND capabilities_id = (SELECT id FROM capabilities WHERE name = 'assign_to_group' AND is_system_supplied = true);" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
This directory stores all KlaudSol CMS plugins. | ||
|
||
This directory is being ignored by Git. | ||
This directory is being ignored by Git. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm not comfortable giving 'Super Admin' special treatment.
I suggest we use the parameterized capabilities, so we have something like:
promote_to(super_admin)
promote_to(admin)
promote_to(registered_user)
etc.
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.
The
promoteToSuperAdmin
variable is somewhat similar to that. It's a variable that can be found from the constants folderIt is equivalent to this:
const promoteToSuperAdmin = '${assignToGroup}(${SUPER_ADMIN_ID})';
Where
assignToGroup
is theassign_to_group
capability and theSUPER_ADMIN_ID
is the id # of the Super Admin group, therefore it is equal toassign_to_group(1)
Should I specifically change this to
capabilities.includes('promote_to(super_admin)')
, wherepromote_to(super_admin)
is a string? (or maybecapabilities.includes('assign_to_group(1)')
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.
🤔