Harden sponsors admin actions: require change permission and make lock POST-only#3035
Open
tonghuaroot wants to merge 1 commit into
Open
Harden sponsors admin actions: require change permission and make lock POST-only#3035tonghuaroot wants to merge 1 commit into
tonghuaroot wants to merge 1 commit into
Conversation
…k POST-only AdminSite.admin_view only checks that the user is active staff, so the custom sponsorship/contract action URLs in apps/sponsors/admin.py did not enforce the per-model permission. Add a require_change_permission decorator applied to each views_admin action. Also give lock_view the same POST + confirmation flow unlock_view already uses, so locking a sponsorship is no longer performed on a plain GET. A new lock.html template mirrors unlock.html.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Hardens the custom sponsorship / contract admin actions.
AdminSite.admin_viewonly checks that the user is active staff, so thecustom action URLs registered in
apps/sponsors/admin.pydid not enforcethe per-model permission. This adds a small
require_change_permissiondecorator (applied to each
views_adminaction) so the actions require themodel's change permission.
It also gives
lock_viewthe same POST + confirmation flow thatunlock_viewalready uses, so locking a sponsorship is no longer performedon a plain GET. A new
lock.htmltemplate mirrors the existingunlock.html.Tests cover the lock confirmation flow (GET does not lock, POST with
confirmation does) and that a staff user without the change permission gets
a 403.
Closes