You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by jl...@apache.org on 2026/09/07 04:17:47 UTC
(superset) branch fix-rls-subjects-role-picker created (now f1a2de05c59)
This is an automated email from the ASF dual-hosted git repository.
sadpandajoe pushed a change to branch fix-rls-subjects-role-picker
in repository https://gitbox.apache.org/repos/asf/superset.git
at f1a2de05c59 fix(row-level-security): allow roles as RLS rule subjects
This branch includes the following new commits:
new f1a2de05c59 fix(row-level-security): allow roles as RLS rule subjects
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: fix(row-level-security): allow roles as RLS rule subjects
Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sadpandajoe pushed a commit to branch fix-rls-subjects-role-picker
in repository https://gitbox.apache.org/repos/asf/superset.git
commit f1a2de05c5918786f3093be4fe36666eaa50bbb9
Author: sadpandajoe <jc...@gmail.com>
AuthorDate: Sat Sep 5 23:18:50 2026 +0000
fix(row-level-security): allow roles as RLS rule subjects
The RLS rule editor's Subjects picker only offered individual users
because SUBJECTS_RELATED_TYPES_RLS defaulted to None and fell back to
the global SUBJECTS_RELATED_TYPES default, which excludes ROLE. Set
an RLS-specific default that includes ROLE so role-scoped RLS rules
(fully supported by the API and data model already) can be created
through the UI, without changing the global picker default used
elsewhere in the app.
---
UPDATING.md | 18 +++++++++---------
docs/admin_docs/security/security.mdx | 28 +++++++++++++++-------------
superset/config.py | 8 +++++++-
tests/unit_tests/subjects/test_filters.py | 25 +++++++++++++++++++++++++
4 files changed, 56 insertions(+), 23 deletions(-)
diff --git a/UPDATING.md b/UPDATING.md
index 786f4add82b..73389839604 100644
--- a/UPDATING.md
+++ b/UPDATING.md
@@ -625,14 +625,16 @@ become active dashboard Viewers after migration.
API clients and automation should send and read `editors`, `viewers`, and `subjects` instead
of the legacy fields.
-Subject pickers support users, groups, and roles, but only users and groups are selectable by
-default. Roles remain supported as Subject types for backwards compatibility with RLS role
+Subject pickers support users, groups, and roles. Dashboard, chart, and alert/report pickers show
+only users and groups by default, while the RLS picker also shows roles to preserve role-based RLS
+workflows. Roles remain supported as Subject types for backwards compatibility with RLS role
assignments and the previous `DASHBOARD_RBAC` model, but they are not recommended for new
resource-specific assignments. Prefer groups for membership-based access and keep roles focused
on capability grants. Existing Role subject assignments remain effective after migration even when
-Roles are hidden from the default dropdown values; configure the relevant `SUBJECTS_RELATED_TYPES_*`
-setting to make Roles selectable when editing subject lists. See the [Security documentation](docs/admin_docs/security/security.mdx#subjects)
-for the full Subject model and picker configuration guidance.
+Roles are hidden from a picker's dropdown values; configure the relevant
+`SUBJECTS_RELATED_TYPES_*` setting to make Roles selectable in non-RLS subject lists. See the
+[Security documentation](docs/admin_docs/security/security.mdx#subjects) for the full Subject model
+and picker configuration guidance.
To make roles selectable everywhere:
@@ -646,15 +648,13 @@ SUBJECTS_RELATED_TYPES = [
]
```
-To make roles selectable for RLS while other pickers keep the user and group default, use the
-RLS-specific override:
+The RLS picker includes users, roles, and groups by default. To customize it, use the RLS-specific
+override. For example, to show only roles:
```python
from superset.subjects.types import SubjectType
SUBJECTS_RELATED_TYPES_RLS = [
- SubjectType.USER,
- SubjectType.GROUP,
SubjectType.ROLE,
]
```
diff --git a/docs/admin_docs/security/security.mdx b/docs/admin_docs/security/security.mdx
index 4b12e7b0e3f..52f6906bdd0 100644
--- a/docs/admin_docs/security/security.mdx
+++ b/docs/admin_docs/security/security.mdx
@@ -143,17 +143,19 @@ dashboards, charts, and datasets. Subjects come in three types:
Subjects are used throughout Superset to assign **editors** (who can modify a resource) and
**viewers** (who can view it). For new resource-specific assignments, Superset defaults to
-**Users** and **Groups** in subject pickers. Groups are the recommended way to grant access to a
-set of people because they represent organizational membership, while roles remain focused on
-capability grants such as "can read dashboards" or "can write charts".
+**Users** and **Groups** in dashboard, chart, and alert/report subject pickers. The Row Level
+Security picker also includes **Roles** by default to preserve role-based RLS workflows. Groups
+are the recommended way to grant access to a set of people because they represent organizational
+membership, while roles remain focused on capability grants such as "can read dashboards" or
+"can write charts".
Role subjects are still supported for backwards compatibility with features that previously used
roles directly, including Row Level Security role assignments and `DASHBOARD_RBAC`. Existing role
subject assignments continue to be enforced even when roles are not exposed in the default picker
-configuration. However, when an administrator edits a subject list, roles are not available as new
-dropdown values unless that picker has been configured to expose role subjects. Roles are not
-recommended for new subject assignments, because using roles for both permissions and resource
-membership couples two separate concerns.
+configuration. The RLS picker exposes roles by default; other subject pickers do not expose roles
+as new dropdown values unless configured to do so. Roles are not recommended for new
+resource-specific assignments, because using roles for both permissions and resource membership
+couples two separate concerns.
Administrators can control which subject types are available in pickers with
`SUBJECTS_RELATED_TYPES`. By default, this setting exposes only users and groups:
@@ -167,8 +169,8 @@ SUBJECTS_RELATED_TYPES = [
]
```
-Set `SUBJECTS_RELATED_TYPES = None` to expose all subject types, including roles. To expose roles
-only for a specific entity, set that entity's override:
+Set `SUBJECTS_RELATED_TYPES = None` to expose all subject types, including roles. The RLS picker
+has the following entity-specific default so role-based RLS rules remain selectable:
```python
from superset.subjects.types import SubjectType
@@ -178,16 +180,16 @@ SUBJECTS_RELATED_TYPES = [
SubjectType.GROUP,
]
-# Leave dashboard, chart, and alert/report overrides unset so they inherit
-# the users + groups default. Expose roles only in the RLS subject picker for
-# compatibility with existing role-based RLS workflows.
SUBJECTS_RELATED_TYPES_RLS = [
SubjectType.USER,
- SubjectType.GROUP,
SubjectType.ROLE,
+ SubjectType.GROUP,
]
```
+Dashboard, chart, and alert/report overrides remain `None` by default and inherit the global
+users-and-groups setting. Set an entity-specific override explicitly to customize its picker.
+
Available per-entity overrides are:
- `SUBJECTS_RELATED_TYPES_DASHBOARDS` for dashboard editor/viewer pickers
diff --git a/superset/config.py b/superset/config.py
index 6886ee48df8..87759b4e07d 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -3178,7 +3178,13 @@ SUBJECTS_RELATED_TYPES: list[SubjectType] | None = [
# None = inherit global behavior.
SUBJECTS_RELATED_TYPES_DASHBOARDS: list[SubjectType] | None = None
SUBJECTS_RELATED_TYPES_CHARTS: list[SubjectType] | None = None
-SUBJECTS_RELATED_TYPES_RLS: list[SubjectType] | None = None
+# Row level security rules are commonly scoped to a role, so the RLS rule
+# editor's Subjects picker exposes roles in addition to the global default.
+SUBJECTS_RELATED_TYPES_RLS: list[SubjectType] | None = [
+ SubjectType.USER,
+ SubjectType.ROLE,
+ SubjectType.GROUP,
+]
SUBJECTS_RELATED_TYPES_ALERT_REPORTS: list[SubjectType] | None = None
diff --git a/tests/unit_tests/subjects/test_filters.py b/tests/unit_tests/subjects/test_filters.py
index efd0e37dba7..b65e7e102f7 100644
--- a/tests/unit_tests/subjects/test_filters.py
+++ b/tests/unit_tests/subjects/test_filters.py
@@ -243,6 +243,31 @@ def test_subject_type_filter_config_default_user_and_group():
assert SUBJECTS_RELATED_TYPES == [SubjectType.USER, SubjectType.GROUP]
+def test_subject_type_filter_rls_config_default_includes_role():
+ """The RLS rule editor's Subjects picker must offer roles by default.
+
+ Row level security rules are commonly scoped to a role rather than an
+ individual user, so RLS should not silently inherit the global picker's
+ exclusion of ROLE.
+ """
+ from superset.config import SUBJECTS_RELATED_TYPES, SUBJECTS_RELATED_TYPES_RLS
+
+ assert SUBJECTS_RELATED_TYPES_RLS == [
+ SubjectType.USER,
+ SubjectType.ROLE,
+ SubjectType.GROUP,
+ ]
+
+ query, result = _apply_subject_type_filter(
+ global_types=SUBJECTS_RELATED_TYPES,
+ entity_types=SUBJECTS_RELATED_TYPES_RLS,
+ entity_key="SUBJECTS_RELATED_TYPES_RLS",
+ )
+ query.filter.assert_called_once()
+ _assert_subject_type_filter_values(query, SUBJECTS_RELATED_TYPES_RLS)
+ assert result is query.filter.return_value
+
+
def test_subject_type_filter_global_only():
"""Global set, entity None -> filters by global types."""
query, result = _apply_subject_type_filter(