Feature: Add Security-Gated Admin Dashboard & Admin Management#510
Feature: Add Security-Gated Admin Dashboard & Admin Management#510rohanmatta11 wants to merge 1 commit intomasterfrom
Conversation
… only), and add owner (owners only). Meant for owner > admin hierarchy
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47c9a7819b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| elif action == 'add_owner': | ||
| target_user.is_staff = True | ||
| target_user.is_superuser = True | ||
| target_user.save() |
There was a problem hiding this comment.
Restrict owner promotion action to superusers
The add_owner branch performs a privilege escalation without validating the caller’s role, so any authenticated staff user can bypass the hidden form and POST action=add_owner to grant superuser access to arbitrary accounts. Since @admin_required only enforces is_staff, this creates a server-side authorization gap that allows non-owner admins to become owners.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This is true. Need to add an additional check. Might be clean to have a single if for all actions that require a superuser and then nest the subconditions.
joshuamotoaki
left a comment
There was a problem hiding this comment.
LGTM, make sure to add this check
| elif action == 'add_owner': | ||
| target_user.is_staff = True | ||
| target_user.is_superuser = True | ||
| target_user.save() |
There was a problem hiding this comment.
This is true. Need to add an additional check. Might be clean to have a single if for all actions that require a superuser and then nest the subconditions.
Security gated admin page that requires users to be Django staff (or superuser) to access. Users without access get redirected to the login page if not signed in and to the course planner/home page if logged in. Staff are able to
Currently, this dashboard allows existing admins to:
Key Changes:
How to Test
Since the dashboard is gated, you must manually promote yourself to access it for the first time.
cd to directory containing manage.py, then run:
Then, run the following commands:
me.is_superuser = Falseand refresh the page. The "Remove Admin" form and "Add Owner" form should disappear.me.is_staff = Falseand refresh. You should be redirected to the home page with an "Access Denied" error message.TIG-188.Pull.Request.Video.mov