Skip to content

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

Merged
JacobCoffee merged 2 commits into
python:mainfrom
tonghuaroot:harden-sponsors-admin-actions
Jul 7, 2026
Merged

Harden sponsors admin actions: require change permission and make lock POST-only#3035
JacobCoffee merged 2 commits into
python:mainfrom
tonghuaroot:harden-sponsors-admin-actions

Conversation

@tonghuaroot

Copy link
Copy Markdown
Contributor

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
@JacobCoffee JacobCoffee enabled auto-merge (squash) July 7, 2026 18:09
@JacobCoffee JacobCoffee merged commit d907160 into python:main Jul 7, 2026
7 checks passed
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

2 participants