Skip to content

feat: add OEP-66 queryset-scoping building blocks for DRF list endpoints - #569

Open
Abdul-Muqadim-Arbisoft wants to merge 1 commit into
openedx:masterfrom
edly-io:feat/oep-66-queryset-scoping-building-blocks
Open

feat: add OEP-66 queryset-scoping building blocks for DRF list endpoints#569
Abdul-Muqadim-Arbisoft wants to merge 1 commit into
openedx:masterfrom
edly-io:feat/oep-66-queryset-scoping-building-blocks

Conversation

@Abdul-Muqadim-Arbisoft

Copy link
Copy Markdown

Add a scoping module providing the reusable record-visibility layer from OEP-66 ("Separating Authorization Concerns in List Endpoints") so DRF list endpoints across the platform and its plugins can share it:

  • ScopingPolicy — a typing.Protocol (structural interface, not an ABC). Implementers need not import or inherit anything; type checkers verify conformance statically. The single method is scope(queryset, subject) (subject, not user, to match the openedx-authz subject-based model).
  • ScopedQuerysetMixin — applies a view's scoping_policy on top of get_queryset(). It duck-type-checks that the policy exposes a callable scope and raises ImproperlyConfigured otherwise.

Using a Protocol + duck-typed runtime check (rather than an ABC) avoids inheritance coupling across repos, keeps interface changes resilient, and lets consumers implement the policy without a hard dependency on this base.

Bumps version to 10.7.0 and adds unit tests.

Add a `scoping` module providing the reusable record-visibility layer from
OEP-66 ("Separating Authorization Concerns in List Endpoints") so DRF list
endpoints across the platform and its plugins can share it:

  * ScopingPolicy — a typing.Protocol (structural interface, not an ABC).
    Implementers need not import or inherit anything; type checkers verify
    conformance statically. The single method is `scope(queryset, subject)`
    (subject, not user, to match the openedx-authz subject-based model).
  * ScopedQuerysetMixin — applies a view's `scoping_policy` on top of
    `get_queryset()`. It duck-type-checks that the policy exposes a callable
    `scope` and raises ImproperlyConfigured otherwise.

Using a Protocol + duck-typed runtime check (rather than an ABC) avoids
inheritance coupling across repos, keeps interface changes resilient, and
lets consumers implement the policy without a hard dependency on this base.

Bumps version to 10.7.0 and adds unit tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant