Skip to content

Conversation

@mariajgrimaldi
Copy link
Member

Description

Make decisions about:

  • How the authz framework will interact with the Open edX ecosystem
  • How the ecosystem will make authorization decisions
  • How the policies used for access control will be managed and stored at the ecosystem level

Merge checklist:
Check off if complete or not applicable:

  • Version bumped
  • Changelog record added
  • 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

Make decisions about:
- How the authz framework will interact with the Open edX ecosystem
- How the ecosystem will make authorization decisions
- How the policies used for access control will be managed and stored at the ecosystem level
@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 Sep 18, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Sep 18, 2025

Thanks for the pull request, @mariajgrimaldi!

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.


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 Sep 18, 2025
@mariajgrimaldi mariajgrimaldi changed the title docs: add ADR proposing architecture for authz framework [FC-0099] docs: add ADR proposing architecture for authz framework Sep 18, 2025
@mariajgrimaldi mariajgrimaldi marked this pull request as ready for review September 18, 2025 18:41
@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Sep 18, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Sep 18, 2025

Interact with the Policy Store via the Open edX Layer
------------------------------------------------------
- The policy store, which can be a database or configuration files (e.g., ``authz.policy``) will be accessed and managed through the Open edX Layer. No direct access to the policy store should be made by services.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should be more explicit when talking about the policy store that it is database that is populated via config file for immutable system wide permissions and also managed via API and UI for dynamic permissions, role configuration, and role assigment... at least if I'm understanding things correctly. 😄

Use a MySQL as the Main Backend for the Policy Store
----------------------------------------------------
- Use MySQL as the main backend for persistent storage for policies (policy store), leveraging Casbin's Django ORM adapter for integration and our own modifications to the adapter as needed in our own ``engine/``` package.
- Use the same schema used by Casbin's Django ORM adapter, which includes a table for storing policies with:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we link out to the Casbin documentation here?

- ``id``: A unique identifier for each policy. This depends on the database backend. In our case, MySQL uses an auto-incrementing integer.
- ``ptype``: The policy type (e.g., ``p`` for policy, ``g, g2`` for grouping).
- ``v0, v1, v2, v3, v4, v5``: The policy fields that define the subject, action, object, and context. The exact meaning of these fields depends on the policy type and model configuration.
- Optionally, include additional metadata fields in the policy table to support auditing and versioning.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these are two different things? We should have as part of this decision what we want to store for auditing and versioning, and it should be non-optional. Whereas metadata fields may be optional?

--------------------------------------
- All policies (i.e., any type of rule) should be stored in the policy store to ensure a single source of truth for authorization.
- Use the policy store to manage RBAC mappings, such as user-role and role-permission assignments, using Casbin's grouping policies (``g, g2``).
- Use Casbin's adapter APIs based on Django APIs to load policies from the policy store into the Authorization Engine at startup and whenever policies are updated.
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is "whenever dynamic policies are updated" and we're not putting a filesystem watcher on the policy file(s) or anything like that?

Maintain Consistent Model and Policy Definitions Across Services
----------------------------------------------------------------
- Policies should be defined in a way that is consistent across services, using the same naming conventions and structures for subjects, actions, objects, and contexts. For example, if the LMS defines a policy for "viewing a course" the CMS should use the same terminology and structure when defining a similar policy for "viewing content".
- Each column in the policy table (v0, v1, v2, etc.) should have a consistent meaning across services. For example, for the same type ``v0`` should always represent the subject, ``v1`` the action, ``v2`` the object, and so on.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's worth noting that a consequence of this is that if the model.conf changes it will possibly change the meaning of the stored data and that data (at least for dynamic policies) may need to be rebuilt somehow? I'm not even sure if that's possible if the definitions of the dynamic policies assume the default model.conf.


Use the Enforcement API for Authorization Decisions for External Clients
------------------------------------------------------------------------
- External clients (e.g., MFEs, IDAs, or any service not co-located with the policy store) must use the REST API provided by the Open edX authorization layer to request authorization decisions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you be specific about which service is going to host this? I assume it will have to be LMS, but I'd like it to be explicit. Things I've read elsewhere seem to indicate that Studio may have its own store? In which case would external services have to query both? Or would both sets of policies be stored in a single LMS-based store with a single set of REST endpoints?


#. **The Framework Requires Client Integration**: To make authorization decisions clients must:
- Call the Open edX Layer's Enforcement API via network with a valid token for authentication and authorization.
- Install the necessary libraries (e.g., openedx-authz) as dependencies to interact with the Open edX Layer directly if they are in-process clients via the Public API (``api.py``). These libraries should be part of the services's ``INSTALLED_APPS`` -for data migration purposes- and requirements files.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a client API in the library that can present the same / similar API to external services as what LMS/CMS get? It could wrap the REST calls, but in the end should be providing the same functionality.

- ``model.conf``: This file contains the Casbin model configuration, defining the structure of policies and how they are evaluated. This file is essential for the Authorization Engine to understand how to process authorization requests. By default, all services share the same ``model.conf`` to ensure consistency in authorization logic across the platform.
- ``authz.policy``: This file contains the default policies for the service. If no policy store is configured, the service will not have any policies so no authorization decisions can be properly made.

#. **Use of MySQL for Policy Storage**: The choice of MySQL as the backend for the policy store means that all policies will be stored in a relational database, which may have implications for performance and scalability. However, this also allows us to leverage existing database infrastructure and tools for managing and querying policies. If support for other databases is needed in the future, we can explore using other Casbin adapters.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how much it matters, but if we're managing these things using the Django ORM we may be able to more specifically say "the LMS database", which can theoretically be Postgres too at this time.


#. **Use of MySQL for Policy Storage**: The choice of MySQL as the backend for the policy store means that all policies will be stored in a relational database, which may have implications for performance and scalability. However, this also allows us to leverage existing database infrastructure and tools for managing and querying policies. If support for other databases is needed in the future, we can explore using other Casbin adapters.

#. **Roles and Permissions are Stored in the Policy Store**: All roles and permissions will be managed through the policy store, which means that any changes to roles or permissions will need to be made via the Policy Management API or by updating the ``authz.policy`` file. This centralization simplifies management but requires careful handling to avoid conflicts or inconsistencies.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't suppose there are any built-in safeguards to keep different apps / services from altering the permissions of others?

@MaferMazu MaferMazu linked an issue Sep 22, 2025 that may be closed by this pull request
@MaferMazu MaferMazu moved this to Ready for testing in RBAC AuthZ Board Oct 22, 2025
@MaferMazu MaferMazu moved this from Ready for review to Blocked in RBAC AuthZ Board Oct 22, 2025
@mariajgrimaldi mariajgrimaldi self-assigned this Nov 5, 2025
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). FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready for Review
Status: Blocked

Development

Successfully merging this pull request may close these issues.

ADR: Open edX AuthZ Architecture

5 participants