Skip to content

feat: add hidden property to permission categories and permissions - #634

Open
BryanttV wants to merge 3 commits into
mainfrom
bav/hidden-categories-and-permissions
Open

BryanttV wants to merge 3 commits into
mainfrom
bav/hidden-categories-and-permissions

Conversation

@BryanttV

@BryanttV BryanttV commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Roles can be hidden with the hidden flag, but permission categories and permissions have no equivalent. Some permissions must keep working without being offered in discovery and selection interfaces, such as the legacy_* compatibility permissions of the course_legacy category, internal actions, or deprecated permissions. Because the role catalog feeds the Custom Roles permission picker, every permission in the schema is currently offered by default.

This PR implements ADR 0038. Permission categories and permissions accept an optional hidden boolean (default false) in their base definitions.

  • A permission is hidden when it sets hidden: true or when its category does.
  • Hidden permissions are left out of the permission catalog and of each role's permissions list. The category catalog only returns categories that still have a visible permission.
  • Hiding is presentation only. Definitions, role grants, permission checks and the rendered Casbin policy do not change.
  • Role extensions cannot change the flag.
  • The flag is added to the JSON schema, the schema loader and definition types, the schema models (migration 0013), the change detection of SchemaApplier, and the compiled schema snapshot.
  • AuthzPermissionDefinition.objects.visible() is added, and get_permission_catalog and get_role_catalog use it.
  • The course_legacy category is now hidden: true, so the legacy compatibility permissions no longer appear in the catalog.

Affected roles: Developers and Operators who define schemas or consume the role catalog API; administrators using the Custom Roles feature no longer see the legacy compatibility permissions.

Supporting Information

  • ADR: docs/decisions/0038-hidden-permission-categories-and-permissions.rst
  • Related ADRs: 0023, 0025, 0028, 0031

Testing Instructions

  1. Check out this branch and apply the migration:

    python manage.py migrate openedx_authz
  2. Run the automated tests:

    pytest src/openedx_authz/tests/api/test_catalog.py src/openedx_authz/tests/schema
  3. Regenerate the compiled schema and verify that there is no diff:

    make compiled_schema
    git diff --exit-code docs/references/compiled-schema.yaml
  4. In docs/references/compiled-schema.yaml, verify that the course_legacy category has hidden: true and that all other categories and permissions have hidden: false.

  5. Request the role catalog for the course-v1 scope type and verify that no legacy_* permission appears in permissions, in any role's permissions, or in categories, and that course_legacy is not listed.

  6. Verify that grants and checks are unchanged: a user with a legacy course role keeps the access they had before this change.

  7. Set hidden: "yes" on a category or permission in a schema file and verify that the schema is rejected as invalid (hidden must be a boolean).

Deadline

Willow

Other Information

  • The migration 0013_add_hidden_to_categories_and_permissions adds two boolean fields with a default of False. It is reversible and does not require a data migration.
  • API clients that need hidden permissions cannot discover them through the role catalog.
  • A role whose permissions are all hidden is still listed, with an empty permissions list.

@BryanttV
BryanttV added this pull request to stack #635 November 17, 2026 17:26
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Nov 17, 2026
@openedx-webhooks

openedx-webhooks commented Nov 17, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @BryanttV!

This repository is currently maintained by @openedx/committers-openedx-authz.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Nov 17, 2026
@BryanttV BryanttV changed the title Bav/hidden categories and permissions feat: add hidden property to permission categories and permissions Nov 17, 2026
@BryanttV
BryanttV force-pushed the bav/hidden-categories-and-permissions branch from 87630ed to 38e53f9 Compare November 17, 2026 17:34
@BryanttV BryanttV linked an issue Nov 17, 2026 that may be closed by this pull request
8 tasks
@BryanttV
BryanttV force-pushed the bav/hidden-categories-and-permissions branch 2 times, most recently from ff2925f to 1853e86 Compare November 17, 2026 22:29
@BryanttV
BryanttV marked this pull request as ready for review November 17, 2026 22:43
scopes:
- lib
icon: Plus
hidden: false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non related to this line but if this is backward compatible should we bump the schema to 1.1? Or are we still considering 1.0 non released yet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! I'd rather keep 1.0 for now. hidden is an optional field that defaults to false, so it's fully backward-compatible: every existing 1.0 file stays valid and means the same thing.

@BryanttV
BryanttV force-pushed the bav/hidden-categories-and-permissions branch from 1853e86 to e56225b Compare November 18, 2026 15:28
@BryanttV
BryanttV force-pushed the bav/hidden-categories-and-permissions branch from 86a5262 to 9142c6a Compare November 18, 2026 15:40
Base automatically changed from bav/docs-hidden-permissions-adr to main November 18, 2026 19:21
BryanttV and others added 3 commits November 18, 2026 14:21
Categories and permissions accept an optional `hidden` flag in the authz
schema, persisted in the schema models. Hidden permissions, and the
permissions of hidden categories, are left out of the role and permission
catalog and of each role's permission list. Role grants and permission
checks are unchanged, and role extensions cannot change the flag.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Mark the course_legacy permission category as hidden so the legacy
compatibility permissions no longer appear in the role and permission
catalog. Role grants and permission checks are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@BryanttV
BryanttV force-pushed the bav/hidden-categories-and-permissions branch from 9142c6a to e44c511 Compare November 18, 2026 19:21
@BryanttV
BryanttV requested a review from rodmgwgu November 18, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

Add hidden property to permission categories and permissions

3 participants