Require publish permission when a save request publishes content
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- authorization, backend-api-design
Research direction
Read _get_xblock_authz_permission and _check_xblock_permission in view_handlers.py, then trace _save_xblock and the existing tests for xblock save permissions. Add or update tests for content edits, make_public, and republish on eligible blocks, including requests that need both permissions. Done means the tests confirm publishing requires publish permission while correctly privileged pure edits and publishes still work; the visibility decision in the issue remains unresolved.
Written by the indexing model from the issue text.
Description
Description
A Course Editor can publish content without having publish_course_content by adding content fields to a request that also sets publish. The permission is chosen from the shape of the request body instead of from what the request does. This is backend only and needs a direct API call.
Current Behavior
_get_xblock_authz_permission (view_handlers.py:216-229) asks for publish_course_content only on a "pure" publish. If the body contains any content field (_CONTENT_FIELDS, :109), it asks for edit_course_content instead. _save_xblock then publishes anyway (:696-702).
Expected Behavior
Any request that will publish requires publish permission, in addition to edit permission when it carries content.
Steps to reproduce
- Log in as a Course Editor (has edit but not publish permission).
- Send an xblock save request to the xblock handler with
publish: "make_public"plus a content field such asmetadata. - Observe that the block is published.
Acceptance Criteria
- A request that publishes (
make_public, orrepublishon a non-direct-only block with a published version) requiresPUBLISH_COURSE_CONTENT. - A request with content fields requires
EDIT_COURSE_CONTENT; a request with both requires both. - An Editor sending content plus
make_publicno longer publishes. - Pure edits and pure publishes by correctly-privileged users keep working.
- Tests are added or updated.
Proposed Solution
needs_publish = publish == "make_public" or (
publish == "republish"
and block_type not in DIRECT_ONLY_CATEGORIES
and modulestore().has_published_version(xblock)
)
Have _get_xblock_authz_permission return a list and _check_xblock_permission require all of them.
Notes or Additional Context
Product decision needed: an editor changing visibility on a published unit. Either deny it (403), or save the change as a draft and downgrade republish to no publish. Second opinion requested on the API-level security validation.
- Dominant language
- Python
- Stars
- 0
- Forks
- 10
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 21
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openedx/openedx-authz
-
willow
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
openedx/openedx-authz#597 ·
Maintainers usually reply within 1 day
-
willow
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
openedx/openedx-authz#579 ·
Maintainers usually reply within 1 day
-
willow
Difficulty 3/5 1-2 days Newbie friendliness 74/100
openedx/openedx-authz#599 ·
Maintainers usually reply within 1 day
-
willow
Difficulty 3/5 1-2 days Newbie friendliness 66/100
openedx/openedx-authz#598 ·
Maintainers usually reply within 1 day
-
willow
Difficulty 4/5 3-5 days Newbie friendliness 55/100
openedx/openedx-authz#596 ·
Maintainers usually reply within 1 day
All issues in openedx/openedx-authz
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
area:docs documentation effort:M ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
mczielinski/ob-analytics#423 ·
Maintainers usually reply within 1 day
-
infra
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 3 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
vllm-project/vllm-ascend#21033 ·
Maintainers usually reply within 1 day