Skip to content

Harden sponsors admin actions: require change permission and make lock POST-only#3035

Open
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:harden-sponsors-admin-actions
Open

Harden sponsors admin actions: require change permission and make lock POST-only#3035
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:harden-sponsors-admin-actions

Conversation

@tonghuaroot

Copy link
Copy Markdown

Description

Hardens the custom sponsorship / contract admin actions.

AdminSite.admin_view only checks that the user is active staff, so the
custom action URLs registered in apps/sponsors/admin.py did not enforce
the per-model permission. This adds a small require_change_permission
decorator (applied to each views_admin action) so the actions require the
model's change permission.

It also gives lock_view the same POST + confirmation flow that
unlock_view already uses, so locking a sponsorship is no longer performed
on a plain GET. A new lock.html template mirrors the existing
unlock.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

…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.
@tonghuaroot tonghuaroot requested a review from JacobCoffee as a code owner June 28, 2026 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Harden sponsors admin actions: require change permission and make lock POST-only

1 participant