Skip to content

feat: add authz supporting subdomain module and ADR-0018#561

Open
mariajgrimaldi wants to merge 5 commits intomainfrom
MJG/authz-audit
Open

feat: add authz supporting subdomain module and ADR-0018#561
mariajgrimaldi wants to merge 5 commits intomainfrom
MJG/authz-audit

Conversation

@mariajgrimaldi
Copy link
Copy Markdown
Member

@mariajgrimaldi mariajgrimaldi commented Apr 14, 2026

Description

This PR introduces the authz module as a supporting subdomain module in openedx-events, along with ADR-0018 to document the pattern.

Authorization events don't belong to any single existing domain module. Role assignments originate from openedx-authz and are consumed across learning, content authoring, enterprise, and other areas. Placing them under course_authoring (the current home of the admin console where role assignment happens today) would tie the module to a UI surface that is expected to move to its own application. ADR-0018 defines the criteria for supporting subdomain modules and establishes analytics as a prior instance of the same concept.

The module adds two public signals:

  • ROLE_ASSIGNMENT_CREATED: emitted when a role is assigned to a subject
  • ROLE_ASSIGNMENT_DELETED: emitted when a role assignment is removed

Both carry RoleAssignmentData, which holds the operation, subject, role, scope, and optional actor. Valid operation values are constrained via RoleAssignmentData.OPERATIONS (a NamedTuple with created and deleted fields), enforced at construction time with attr.validators.in_.

Design decisions are documented in docs/decisions/0018-supporting-subdomain-modules.rst.

Supporting information

Testing instructions

See openedx/openedx-authz#261 for end-to-end testing instructions.

Deadline

None.

Other information

  • The analytics module is the prior instance of the supporting subdomain pattern; this PR makes that classification explicit in ADR-0018.
  • No existing signals or data classes are modified.

Checklists

Merge Checklist:

  • All reviewers approved
  • Reviewer tested the code following the testing instructions
  • CI build is green
  • Version bumped
  • Changelog record added with short description of the change and current date
  • Documentation updated (not only docstrings)
  • Integration with other services reviewed
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets

Post Merge:

  • Create a tag
  • Create a release on GitHub
  • Check new version is pushed to PyPI after tag-triggered build is finished.
  • Delete working branch (if not needed anymore)
  • Upgrade the package in the Open edX platform requirements (if applicable)

@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 Apr 14, 2026
@openedx-webhooks
Copy link
Copy Markdown

openedx-webhooks commented Apr 14, 2026

Thanks for the pull request, @mariajgrimaldi!

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

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.

Introduces openedx_events/authz with ROLE_ASSIGNMENT_CREATED and R
OLE_ASSIGNMENT_DELETED events. ADR-0018 documents the decision to
use dedicated top-level modules for supporting subdomains, with authz
module is recognized as a prior instance of the same concept.
as the first application of that pattern after analytics in
#230
Introduces openedx_events/authz with ROLE_ASSIGNMENT_CREATED and ROLE_ASSIGNMENT_DELETED events. ADR-0018 documents the decision to use dedicated top-level modules for supporting subdomains, with authz as the first application of that pattern. The existing analytics module is recognized as a prior instance of the same concept.
… username

- Add Operations NamedTuple with `created` and `deleted` constants so
  callers use RoleAssignmentData.OPERATIONS.created instead of bare strings
- Add attr.validators.in_ to enforce valid operation values at construction time
- Rename actor field from Optional[str] (free-form) to Optional[str] carrying
  the username of the performing user, documented as actor
@mariajgrimaldi mariajgrimaldi changed the title Mjg/authz audit feat: add authz supporting subdomain module and ADR-0018 Apr 15, 2026
…signals

Remove constrained validator from operation field (incompatible with Avro
test infra), align field definitions to repo attrs convention, and generate
Avro schemas for ROLE_ASSIGNMENT_CREATED and ROLE_ASSIGNMENT_DELETED.
@mariajgrimaldi mariajgrimaldi marked this pull request as ready for review April 15, 2026 18:55
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Apr 16, 2026
Copy link
Copy Markdown

@rodmgwgu rodmgwgu left a comment

Choose a reason for hiding this comment

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

I'm not very familiar with this module, but the ADR and implementation looks good to me.

Please update the version and CHANGELOG once this is ready to merge, thanks!

Copy link
Copy Markdown
Contributor

@bmtcril bmtcril left a comment

Choose a reason for hiding this comment

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

This looks great, I think there is still the open question about persisting usernames in the audit logs but using the username here, where it's possible to be a cross-boundary identifier that pk can't fulfill makes sense to me.

Copy link
Copy Markdown
Member

@felipemontoya felipemontoya left a comment

Choose a reason for hiding this comment

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

I think this is clear (thanks for the ADR), well though and warranted.

"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
"fields": [
{
"name": "role_assignment",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Quick question, I’m not familiar with these events. Should we add a suffix like _delete here?

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: Ready for Review

Development

Successfully merging this pull request may close these issues.

7 participants