Skip to content

feat: add filesystem-path schema discovery and multi-document YAML loading - #534

Draft
carlos-marquez-wgu wants to merge 1 commit into
openedx:mainfrom
WGU-Open-edX:carlos-marquez-wgu/schema-discovery-tutor-patch-implementation
Draft

carlos-marquez-wgu wants to merge 1 commit into
openedx:mainfrom
WGU-Open-edX:carlos-marquez-wgu/schema-discovery-tutor-patch-implementation

Conversation

@carlos-marquez-wgu

@carlos-marquez-wgu carlos-marquez-wgu commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Implements ADR 0029: Tutor integration for authorization schema discovery.

  • Add OPENEDX_AUTHZ_SCHEMA_FILES Django setting for discovering schema files by absolute filesystem path (discovery.py)
  • Introduce DiscoveredFileResource and SourceFileRecord with sentinel values for non-package sources
  • Switch YAML parsing from safe_load to safe_load_all so each schema resource is treated as a multi-document stream (loading.py)
  • Add tests for filesystem discovery, multi-document streams, and filesystem source identity
  • Add tutor plugin to load Authorization schemas contributed through the openedx-authz-schema patch. Most of it is the output of cookiecutter, leaving it as is for future tutor related changes regarding openedx-authz

Testing instructions

  1. Install tutor-contrib-authz plugin
pip installl -e tutor/tutor-contrib-authz
  1. Enable it
tutor plugins enable authz
  1. Create a tutor patch to contribute to the authz schema
touch $(tutor config printroot)-plugins/my_authz_schema.py
  1. Add the schema contents to my_authz_schema.py
from tutor import hooks

hooks.Filters.ENV_PATCHES.add_item(
    (
        "openedx-authz-schema",
        """
schema_version: "1.0"
priority: 100

role_extensions:
- role_id: course_editor
  add_permissions:
    - courses.export_course
  remove_permissions:
    - courses.manage_tags
  display_name: Course author
  description: Creates and exports course content for this site.
        """,
    )
)
  1. Enable your patch
tutor plugins enable my_authz_schema
  1. Either run do init tasks or run the load_authz_schema management command directly
tutor dev do init
  1. With the management command
tutor dev run cms ./manage.py cms load_authz_schema
  1. Console should output the newly applied schema:
Authz schema apply: added 1 p row(s), removed 1 p row(s).

Changes to apply:

Casbin policies (2)
  + p, role^course_editor, act^courses.export_course, course-v1^*, allow
  - p, role^course_editor, act^courses.manage_tags, course-v1^*, allow

Definitions (3)
  ~ role: course_editor
  + role-permission: course_editor -> courses.export_course @ course-v1
  - role-permission: course_editor -> courses.manage_tags @ course-v1

Authz schema applied: 1 Casbin policy row(s) added, 1 removed; definition changes: 1 role, 2 role-permission.
  1. To roll back the schema changes: disable the patch and run the management command again
tutor plugins disable my_authz_schema
tutor dev run cms ./manage.py cms load_authz_schema

Merge checklist:
Check off if complete or not applicable:

  • Documentation updated (not only docstrings)
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Manual testing instructions provided
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets

AI Usage

Kiro + Claude were used to assist with the creation of the tests and code implementations while throughly and carefully guided, everything was reviewed and corrected manually by an actual person and ensured the changes were up to standard and met the closing issue requirements.

Closes:

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 14, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @carlos-marquez-wgu!

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.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


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 Oct 14, 2026
@carlos-marquez-wgu
carlos-marquez-wgu force-pushed the carlos-marquez-wgu/schema-discovery-tutor-patch-implementation branch 2 times, most recently from dbddb51 to 3cb134e Compare October 14, 2026 18:15
…ading

Implement ADR 0029: Tutor integration for authorization schema discovery.

- Add OPENEDX_AUTHZ_SCHEMA_FILES Django setting for discovering schema
  files by absolute filesystem path (discovery.py)
- Introduce DiscoveredFileResource and SourceFileRecord with sentinel
  values for non-package sources
- Switch YAML parsing from safe_load to safe_load_all so each schema
  resource is treated as a multi-document stream (loading.py)
- Add tests for filesystem discovery, multi-document streams, and
  filesystem source identity
- Add tutor plugin
@carlos-marquez-wgu
carlos-marquez-wgu force-pushed the carlos-marquez-wgu/schema-discovery-tutor-patch-implementation branch from 3cb134e to 7a334b5 Compare October 19, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants