Skip to content

fix: require change permission for exercise updates#2306

Closed
Bojun-Vvibe wants to merge 1 commit intowger-project:masterfrom
Bojun-Vvibe:agent/wger-project_wger-1776719765
Closed

fix: require change permission for exercise updates#2306
Bojun-Vvibe wants to merge 1 commit intowger-project:masterfrom
Bojun-Vvibe:agent/wger-project_wger-1776719765

Conversation

@Bojun-Vvibe
Copy link
Copy Markdown

Repo: wger-project/wger (⭐ 5970)
Type: bugfix
Files changed: 2
Lines: +54/-1

What

This change fixes CanContributeExercises so POST still requires exercises.add_exercise, but PUT and PATCH now correctly require exercises.change_exercise. It also adds a focused regression test module that exercises the permission class directly and covers the create-vs-update distinction.

Why

Before this patch, update requests were grouped with create requests, so a user with update rights but without create rights could not edit exercise data through the API. That is a real authorization bug because it blocks a valid permission combination and makes the permission class stricter than the underlying Django permission model.

Testing

Verified syntax locally with python -m compileall wger/exercises/api/permissions.py wger/exercises/tests/api/test_permissions.py.
Attempted python manage.py test wger.exercises.tests.api.test_permissions, but the active interpreter does not have Django installed.
Attempted UV_CACHE_DIR=/tmp/uv-cache uv run --group dev python manage.py test wger.exercises.tests.api.test_permissions, but dependency resolution could not complete because network access is unavailable in the sandbox.

Risk

Low / the change is narrowly scoped to request-method permission mapping and adds regression coverage for the exact permission split.

@Bojun-Vvibe Bojun-Vvibe closed this by deleting the head repository Apr 21, 2026
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.

2 participants