Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ Added
* ``assign_role_to_subject_in_scope`` now raises ``CustomRoleNotFoundError`` for a custom role that
does not exist or was removed. It assigns custom roles under the same lock as removing them, so
an assignment cannot outlive a concurrent removal. Static role assignments are unchanged.
* Added authorization schema version ``1.1``, with its own ``authz-schema-v1.1.json``. It adds an
optional ``depends_on`` list to permissions (ADR 0034). Files of versions ``1.0`` and ``1.1`` can
be loaded together. Validation rejects unknown dependencies, dependency cycles, dependencies that
do not support the dependent permission's scopes, visible permissions that depend on hidden
ones, and roles that grant a permission without all of its dependencies.
* Added an optional ``hidden`` flag to permission categories and permissions in the authorization
schema. Hidden permissions, and the permissions of hidden categories, are left out of the
role and permission catalog, including each role's permission list, but keep their role grants
Expand Down Expand Up @@ -117,6 +122,9 @@ Changed
return a 400 validation error, the same as ``/roles/``.
* The role catalog now lists roles by display name by default, instead of by role identifier.
Pass ``sort_by`` and ``order`` to choose another order.
* Replaced the ``OPENEDX_AUTHZ_JSON_SCHEMA`` setting with ``OPENEDX_AUTHZ_JSON_SCHEMAS``, which maps
``schema_version`` values to JSON Schema resources. It overrides only the versions it lists, and
the built-in schemas cover the rest. Setting the old name raises ``ImproperlyConfigured``.

Removed
=======
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ Addendum: Indirect Dependencies in the Catalog (2026-11-17)

`ADR 0036`_ adds ``all_depends_on`` to each permission in the role catalog, next to ``depends_on``. It lists every direct and indirect dependency, so clients no longer compute indirect dependencies themselves. This replaces the last part of section 6.

Addendum: Visible Permissions Cannot Depend on Hidden Ones (2026-11-26)
=======================================================================

Validation also rejects a visible permission that depends on a hidden one. A permission is hidden when it, or its category, is hidden (`ADR 0038`_). This adds a rule to section 3.

The rule exists because hidden permissions are left out of the role catalog and a custom role cannot grant them. A custom role that grants the visible permission could never include its dependency, and the catalog would ask clients to select a permission it never lists.

Only direct dependencies are checked. This also covers indirect ones, because any chain from a visible permission to a hidden one contains a visible permission that directly depends on a hidden one.

Rejected Alternatives
*********************

Expand Down Expand Up @@ -151,6 +160,7 @@ References
* `ADR 0028`_
* `ADR 0031`_
* `ADR 0036`_
* `ADR 0038`_
* `Issue #91`_
* `Issue #523`_
* `PR #538`_
Expand All @@ -163,6 +173,7 @@ References
.. _ADR 0028: 0028-api-contract-for-role-catalog.rst
.. _ADR 0031: 0031-priority-applies-to-role-extensions-only.rst
.. _ADR 0036: 0036-api-contract-for-custom-roles.rst
.. _ADR 0038: 0038-hidden-permission-categories-and-permissions.rst
.. _Issue #91: https://github.com/openedx/openedx-authz/issues/91
.. _Issue #523: https://github.com/openedx/openedx-authz/issues/523
.. _PR #538: https://github.com/openedx/openedx-authz/pull/538
Expand Down
71 changes: 37 additions & 34 deletions docs/references/authorization-schema-json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,122 +3,125 @@
Generated Authorization Schema
##############################

This page renders the exact validation rules from the :download:`authz JSON Schema <../../src/openedx_authz/engine/schema/authz-schema-v1.json>`. See the :doc:`Authorization Schema Reference <authorization-schema>` for guidance, examples, and validation performed by the compiler across schema contributions.
This page renders the exact validation rules from the :download:`authz JSON Schema <../../src/openedx_authz/engine/schema/authz-schema-v1.1.json>` for schema version ``1.1``, the current version. The :download:`version 1.0 JSON Schema <../../src/openedx_authz/engine/schema/authz-schema-v1.json>` accepts the same fields except the permission ``depends_on`` field. See the :doc:`Authorization Schema Reference <authorization-schema>` for guidance, examples, and validation performed by the compiler across schema contributions.

Top-level fields
****************

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/properties/schema_version
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/properties/schema_version
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/properties/priority
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/properties/priority
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/properties/permission_categories
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/properties/permission_categories
:lift_description:
:hide_key: /items

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/properties/permissions
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/properties/permissions
:lift_description:
:hide_key: /items

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/properties/roles
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/properties/roles
:lift_description:
:hide_key: /items

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/properties/role_extensions
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/properties/role_extensions
:lift_description:
:hide_key: /items

Permission category fields
**************************

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission_category/properties/id
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission_category/properties/id
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission_category/properties/display_name
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission_category/properties/display_name
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission_category/properties/description
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission_category/properties/description
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission_category/properties/icon
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission_category/properties/icon
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission_category/properties/hidden
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission_category/properties/hidden
:lift_description:

Permission fields
*****************

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission/properties/namespace
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission/properties/namespace
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission/properties/name
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission/properties/name
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission/properties/display_name
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission/properties/display_name
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission/properties/description
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission/properties/description
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission/properties/category_id
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission/properties/category_id
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission/properties/scopes
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission/properties/scopes
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission/properties/icon
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission/properties/icon
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/permission/properties/hidden
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission/properties/hidden
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/permission/properties/depends_on
:lift_description:

Role fields
***********

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role/properties/id
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role/properties/id
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role/properties/display_name
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role/properties/display_name
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role/properties/description
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role/properties/description
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role/properties/scopes
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role/properties/scopes
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role/properties/permissions
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role/properties/permissions
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role/properties/icon
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role/properties/icon
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role/properties/hidden
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role/properties/hidden
:lift_description:

Role extension fields
*********************

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role_extension/properties/role_id
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role_extension/properties/role_id
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role_extension/properties/add_permissions
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role_extension/properties/add_permissions
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role_extension/properties/remove_permissions
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role_extension/properties/remove_permissions
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role_extension/properties/display_name
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role_extension/properties/display_name
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role_extension/properties/description
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role_extension/properties/description
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role_extension/properties/icon
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role_extension/properties/icon
:lift_description:

.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.json#/$defs/role_extension/properties/hidden
.. jsonschema:: ../../src/openedx_authz/engine/schema/authz-schema-v1.1.json#/$defs/role_extension/properties/hidden
:lift_description:
47 changes: 44 additions & 3 deletions docs/references/authorization-schema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ Use this reference when creating or reviewing an authz schema file. The examples
Machine-readable schema
***********************

The :download:`downloadable authz JSON Schema <../../src/openedx_authz/engine/schema/authz-schema-v1.json>` describes the fields, types, required values, and identifier formats for schema version ``1.0``. You can also :doc:`browse the generated schema <authorization-schema-json>` or `view the schema source <https://github.com/openedx/openedx-authz/blob/main/src/openedx_authz/engine/schema/authz-schema-v1.json>`_. Editors and validation tools can use it to check YAML files because JSON Schema applies to the data represented by both JSON and YAML.
Each schema version has a downloadable authz JSON Schema that describes its fields, types, required values, and identifier formats:

* :download:`authz-schema-v1.json <../../src/openedx_authz/engine/schema/authz-schema-v1.json>` for schema version ``1.0`` (`view source <https://github.com/openedx/openedx-authz/blob/main/src/openedx_authz/engine/schema/authz-schema-v1.json>`__).
* :download:`authz-schema-v1.1.json <../../src/openedx_authz/engine/schema/authz-schema-v1.1.json>` for schema version ``1.1`` (`view source <https://github.com/openedx/openedx-authz/blob/main/src/openedx_authz/engine/schema/authz-schema-v1.1.json>`__). It accepts everything ``1.0`` accepts and adds the optional ``depends_on`` field to permissions.

You can also :doc:`browse the generated schema <authorization-schema-json>`. Editors and validation tools can use these files to check YAML files because JSON Schema applies to the data represented by both JSON and YAML.

The JSON Schema checks the structure of one file. The compiler also checks references across the combined schema, registered scope namespaces, available Paragon icons, and conflicts between contributions.

Expand Down Expand Up @@ -81,6 +86,8 @@ Top-level fields

The version of the YAML format used by the file. Write it as a quoted ``major.minor`` value, such as ``"1.0"``. A deployment stops before changing the database when it encounters a version it cannot read.

The supported versions are ``"1.0"`` and ``"1.1"``. Each file is validated against the JSON Schema of the version it declares, so a deployment can load files of both versions together, and a file can move to ``1.1`` without the other files moving with it. A file needs ``"1.1"`` only to declare ``depends_on``, and a ``1.1`` file without it means the same as it would in ``1.0``. A ``1.0`` file that declares it fails validation with an unknown-field error.

``priority``
============

Expand Down Expand Up @@ -167,6 +174,9 @@ A permission contains these fields:
``hidden``
An optional boolean that defaults to ``false``. A hidden permission does not appear in normal discovery and selection interfaces or in role details. Hiding does not delete the permission, remove it from roles, or change permission checks. Role extensions cannot change this field.

``depends_on``
An optional list of the complete IDs of the permissions this permission directly requires. Only the file that defines a permission declares its dependencies, and role extensions cannot add or remove them. Requires schema version ``1.1``. See :doc:`ADR 0034 <../decisions/0034-permission-dependencies-in-authorization-schema>`.

The complete permission ID joins ``namespace`` and ``name`` with a period. For example:

.. code-block:: yaml
Expand All @@ -184,6 +194,37 @@ The complete ID is ``content_libraries.manage_library_tags``. Role definitions,

The Casbin form ``act^content_libraries.manage_library_tags`` is an internal value and is not valid in a schema file.

Permission dependencies
=======================

A permission declares the permissions it directly requires in ``depends_on``. For example, editing library content requires viewing the library:

.. code-block:: yaml

schema_version: "1.1"
priority: 100

permissions:
- namespace: content_libraries
name: edit_library_content
display_name: Edit library content
description: Create, edit, and delete content in a content library.
category_id: library_content
scopes:
- lib
depends_on:
- content_libraries.view_library

Validation rejects a schema when:

* a dependency is not a permission defined in the combined schema;
* a permission depends on itself, or permissions depend on each other in a cycle;
* a dependency does not support every scope of the permission that depends on it;
* a visible permission depends on a hidden permission, or on a permission in a hidden category; or
* a role, after role extensions are applied, grants a permission without all of its direct and indirect dependencies.

The last rule applies to roles and role extensions in every file, whatever ``schema_version`` the file declares. If a ``1.1`` file adds ``depends_on`` to a permission, every role that grants that permission must also list its dependencies.

Roles
*****

Expand All @@ -202,7 +243,7 @@ A role contains these fields:
The scope namespaces where the role can be assigned. Every permission listed by the role must support those scopes.

``permissions``
A list of complete permission IDs. The compiler does not infer one permission from another, so the role lists every permission it needs.
A list of complete permission IDs. The role lists every permission it needs, including every direct and indirect dependency of those permissions (see `Permission dependencies`_).

``icon``
An optional, case-sensitive icon name exported by ``@openedx/paragon/icons``.
Expand Down Expand Up @@ -266,7 +307,7 @@ For example, a deployment can allow course editors to export courses, remove the
- role_id: course_auditor
hidden: true

An extension fails validation when its target role or a referenced permission does not exist. Adding a permission already assigned to the role or removing one the role does not have produces a warning and leaves the result unchanged.
An extension fails validation when its target role or a referenced permission does not exist. It also fails when the resulting role grants a permission without its dependencies: an extension that adds a permission must also add the dependencies the role lacks, and ``remove_permissions`` cannot remove a dependency that another permission on the role still needs. Adding a permission already assigned to the role or removing one the role does not have produces a warning and leaves the result unchanged.

Identifier rules
****************
Expand Down
Loading