fix: require change permission for exercise updates#2306
Closed
Bojun-Vvibe wants to merge 1 commit intowger-project:masterfrom
Closed
fix: require change permission for exercise updates#2306Bojun-Vvibe wants to merge 1 commit intowger-project:masterfrom
Bojun-Vvibe wants to merge 1 commit intowger-project:masterfrom
Conversation
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.
Repo: wger-project/wger (⭐ 5970)
Type: bugfix
Files changed: 2
Lines: +54/-1
What
This change fixes
CanContributeExercisessoPOSTstill requiresexercises.add_exercise, butPUTandPATCHnow correctly requireexercises.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.