Skip to content

Require publish permission when a save request publishes content #600

In progress
openedx/openedx-platform
#39423

Description

@BryanttV

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

  1. Log in as a Course Editor (has edit but not publish permission).
  2. Send an xblock save request to the xblock handler with publish: "make_public" plus a content field such as metadata.
  3. Observe that the block is published.

Acceptance Criteria

  • A request that publishes (make_public, or republish on a non-direct-only block with a published version) requires PUBLISH_COURSE_CONTENT.
  • A request with content fields requires EDIT_COURSE_CONTENT; a request with both requires both.
  • An Editor sending content plus make_public no 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.

Activity

  1. added
    willow
    on Nov 4, 2026
  2. added theissue type on Nov 4, 2026
  3. moved this to Ready for Development in RBAC AuthZ Boardon Nov 5, 2026
  4. moved this from Ready for Development to In Progress in RBAC AuthZ Boardon Nov 23, 2026
  5. efortish commented on Nov 23, 2026

    @efortish
    Contributor

    Draft fix is up in openedx/openedx-platform#39423. It follows the acceptance criteria: a save request that publishes (make_public, or republish on a non direct-only block that already has a published version) now requires publish_course_content in addition to edit_course_content. On a devstack, an Editor sending content plus make_public now gets a 403 and nothing is published (on master the unit was published).

    It's a draft because of the product question in the issue, and I think we need an answer before it merges.

    What happens when an Editor changes a published unit through republish?

    The authoring MFE sends republish plus metadata from the unit Configure modal (name, visibility, group access) and from component "Manage access". It hides the Publish buttons when the user can't publish, but these dialogs stay available to Editors. Today the change goes live right away, which is the bug. The options:

    1. Deny it (403). This is what the PR does now. It's the simplest and strictest option, but an Editor using those dialogs on a published unit gets an error, so the MFE would need to hide them or explain why the save failed.
    2. Save as a draft. Save the change but skip the publish for users without publish permission (downgrade republish to no publish). The unit then shows unpublished changes, and someone with publish permission publishes it. Editors keep a working UI, but the API silently does less than the request asked for.

    I'd lean towards 2, because it matches the "Editor edits, Staff publishes" split and doesn't break the MFE for Editors. Happy to switch the PR to it if we agree.

    Also, as the issue asks, a second opinion on the API-level validation would be welcome. The fix decides in the permission check whether the save will publish, by mirroring the publish logic at the end of _save_xblock (_save_publishes). If someone sees a publish path that bypasses that check, please point it out.

    @BryanttV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

willow

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions