You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2025/12/18 02:52:40 UTC

(superset) branch new-dar updated (c5d2329297 -> 3ad694e5a9)

This is an automated email from the ASF dual-hosted git repository.

beto pushed a change to branch new-dar
in repository https://gitbox.apache.org/repos/asf/superset.git


    from c5d2329297 CLS implementation
     new b66729ad08 RLS
     new 3ad694e5a9 Add name and description

The 2 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.


Summary of changes:
 .../dataAccessRules/DataAccessRuleModal.tsx        |  68 ++++++-----
 .../dataAccessRules/PermissionsTree/index.tsx      | 135 +++++++++++++++++++--
 .../dataAccessRules/PermissionsTree/types.ts       |  12 +-
 .../dataAccessRules/PermissionsTree/utils.ts       |  64 ++++++++--
 .../src/features/dataAccessRules/types.ts          |   2 +
 .../src/pages/DataAccessRulesList/index.tsx        |  48 +++++---
 superset/data_access_rules/api.py                  |   9 ++
 superset/data_access_rules/models.py               |   6 +-
 superset/data_access_rules/schemas.py              |  24 ++++
 ...0_add_name_description_to_data_access_rules.py} |  20 +--
 10 files changed, 315 insertions(+), 73 deletions(-)
 copy superset/migrations/versions/{2025-03-03_20-52_94e7a3499973_add_folders_column_to_dataset.py => 2025-12-17_12-00_b463d8709290_add_name_description_to_data_access_rules.py} (71%)


(superset) 01/02: RLS

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

beto pushed a commit to branch new-dar
in repository https://gitbox.apache.org/repos/asf/superset.git

commit b66729ad087a4fe202a266f9be58d8f09bd2cde3
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Dec 17 21:36:04 2025 -0500

    RLS
---
 .../dataAccessRules/PermissionsTree/index.tsx      | 117 ++++++++++++++++++++-
 .../dataAccessRules/PermissionsTree/types.ts       |  12 ++-
 .../dataAccessRules/PermissionsTree/utils.ts       |  64 +++++++++--
 3 files changed, 183 insertions(+), 10 deletions(-)

diff --git a/superset-frontend/src/features/dataAccessRules/PermissionsTree/index.tsx b/superset-frontend/src/features/dataAccessRules/PermissionsTree/index.tsx
index 39e1f71cf7..4853977da9 100644
--- a/superset-frontend/src/features/dataAccessRules/PermissionsTree/index.tsx
+++ b/superset-frontend/src/features/dataAccessRules/PermissionsTree/index.tsx
@@ -20,7 +20,7 @@
 import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
 import { t } from '@superset-ui/core';
 import { css, styled } from '@apache-superset/core/ui';
-import { Tree, Tooltip, Spin, Button, Select } from 'antd';
+import { Tree, Tooltip, Spin, Button, Select, Input } from 'antd';
 import {
   CheckCircleOutlined,
   CloseCircleOutlined,
@@ -36,6 +36,7 @@ import type {
   TreeState,
   PermissionsPayload,
   CLSAction,
+  RLSRule,
 } from './types';
 import {
   fetchDatabases,
@@ -136,6 +137,33 @@ const StyledContainer = styled.div`
       font-size: 11px;
       color: ${theme.colorTextSecondary};
     }
+
+    .rls-container {
+      display: flex;
+      flex-direction: column;
+      gap: ${theme.sizeUnit}px;
+      padding: ${theme.sizeUnit}px 0;
+      margin-bottom: ${theme.sizeUnit}px;
+      border-bottom: 1px dashed ${theme.colorBorder};
+    }
+
+    .rls-row {
+      display: flex;
+      align-items: center;
+      gap: ${theme.sizeUnit}px;
+    }
+
+    .rls-label {
+      font-size: 11px;
+      color: ${theme.colorTextSecondary};
+      min-width: 70px;
+    }
+
+    .rls-input {
+      flex: 1;
+      max-width: 250px;
+      font-size: 12px;
+    }
   `}
 `;
 
@@ -156,6 +184,7 @@ function PermissionsTree({
     treeData: [],
     permissionStates: {},
     clsRules: {},
+    rlsRules: {},
   });
   const [loading, setLoading] = useState(false);
   const [databases, setDatabases] = useState<DatabaseInfo[]>([]);
@@ -186,7 +215,7 @@ function PermissionsTree({
       return;
     }
     if (value && databaseMaps.nameToId.size > 0) {
-      const { states, clsRules } = loadPermissionsFromPayload(
+      const { states, clsRules, rlsRules } = loadPermissionsFromPayload(
         value,
         databaseMaps.nameToId,
       );
@@ -194,6 +223,7 @@ function PermissionsTree({
         ...prev,
         permissionStates: states,
         clsRules,
+        rlsRules,
       }));
     }
   }, [value, databaseMaps.nameToId]);
@@ -409,11 +439,50 @@ function PermissionsTree({
         newStates,
         databaseMaps.idToName,
         treeState.clsRules,
+        treeState.rlsRules,
       );
       onChange(payload);
     }
   };
 
+  const handleRlsChange = (
+    tableKey: string,
+    field: 'predicate' | 'groupKey',
+    value: string,
+  ) => {
+    // Mark as internal update to prevent circular updates
+    isInternalUpdateRef.current = true;
+
+    setTreeState(prev => {
+      const currentRls = prev.rlsRules[tableKey] || { predicate: '' };
+      const newRls: RLSRule = { ...currentRls, [field]: value };
+
+      // Remove the rule if both fields are empty
+      const newRlsRules = { ...prev.rlsRules };
+      if (!newRls.predicate && !newRls.groupKey) {
+        delete newRlsRules[tableKey];
+      } else {
+        newRlsRules[tableKey] = newRls;
+      }
+
+      // Notify parent of changes
+      if (onChange && databaseMaps.idToName.size > 0) {
+        const payload = generatePermissionsPayload(
+          prev.permissionStates,
+          databaseMaps.idToName,
+          prev.clsRules,
+          newRlsRules,
+        );
+        onChange(payload);
+      }
+
+      return {
+        ...prev,
+        rlsRules: newRlsRules,
+      };
+    });
+  };
+
   const handleClsChange = (
     tableKey: string,
     columnName: string,
@@ -438,6 +507,7 @@ function PermissionsTree({
           prev.permissionStates,
           databaseMaps.idToName,
           newClsRules,
+          prev.rlsRules,
         );
         onChange(payload);
       }
@@ -554,6 +624,48 @@ function PermissionsTree({
       );
     }
 
+    // Table nodes get RLS inputs when expanded
+    if (node.nodeType === 'table' && isExpanded) {
+      const currentRls = treeState.rlsRules[nodeKey] || {
+        predicate: '',
+        groupKey: '',
+      };
+
+      return (
+        <div>
+          <div className="node-title">
+            {getStateIcon(nodeKey)}
+            {getNodeIcon(node.nodeType)}
+            <span>{title}</span>
+          </div>
+          <div className="rls-container">
+            <div className="rls-row">
+              <span className="rls-label">{t('RLS Predicate')}</span>
+              <Input
+                className="rls-input"
+                size="small"
+                placeholder={t('e.g., org_id = {{current_user_id}}')}
+                value={currentRls.predicate}
+                onChange={e => handleRlsChange(nodeKey, 'predicate', e.target.value)}
+                onClick={e => e.stopPropagation()}
+              />
+            </div>
+            <div className="rls-row">
+              <span className="rls-label">{t('Group Key')}</span>
+              <Input
+                className="rls-input"
+                size="small"
+                placeholder={t('Optional grouping key')}
+                value={currentRls.groupKey || ''}
+                onChange={e => handleRlsChange(nodeKey, 'groupKey', e.target.value)}
+                onClick={e => e.stopPropagation()}
+              />
+            </div>
+          </div>
+        </div>
+      );
+    }
+
     // Non-column nodes: check if leaf (columns are leafs, tables are not anymore)
     const isLeaf = node.nodeType === 'column';
 
@@ -597,6 +709,7 @@ function PermissionsTree({
       ...prev,
       permissionStates: {},
       clsRules: {},
+      rlsRules: {},
     }));
     if (onChange) {
       onChange({ allowed: [], denied: [] });
diff --git a/superset-frontend/src/features/dataAccessRules/PermissionsTree/types.ts b/superset-frontend/src/features/dataAccessRules/PermissionsTree/types.ts
index b77751dfae..23d1b32802 100644
--- a/superset-frontend/src/features/dataAccessRules/PermissionsTree/types.ts
+++ b/superset-frontend/src/features/dataAccessRules/PermissionsTree/types.ts
@@ -41,12 +41,18 @@ export interface PermissionNode extends DataNode {
   totalCount?: number;
 }
 
+export interface RLSRule {
+  predicate: string;
+  groupKey?: string;
+}
+
 export interface TreeState {
   expandedKeys: string[];
   loadedKeys: string[];
   treeData: PermissionNode[];
   permissionStates: Record<string, PermissionState>;
-  clsRules: Record<string, CLSAction>; // key format: "tableKey:columnName" -> action
+  clsRules: Record<string, CLSAction>; // key format: "tableKey::columnName" -> action
+  rlsRules: Record<string, RLSRule>; // key format: tableKey -> RLSRule
 }
 
 export interface PermissionsPayload {
@@ -59,5 +65,9 @@ export interface PermissionEntry {
   catalog?: string;
   schema?: string;
   table?: string;
+  rls?: {
+    predicate: string;
+    group_key?: string;
+  };
   cls?: Record<string, string>; // column name -> action
 }
diff --git a/superset-frontend/src/features/dataAccessRules/PermissionsTree/utils.ts b/superset-frontend/src/features/dataAccessRules/PermissionsTree/utils.ts
index ab2636e733..ede38799a5 100644
--- a/superset-frontend/src/features/dataAccessRules/PermissionsTree/utils.ts
+++ b/superset-frontend/src/features/dataAccessRules/PermissionsTree/utils.ts
@@ -24,6 +24,7 @@ import type {
   PermissionEntry,
   NodeType,
   CLSAction,
+  RLSRule,
 } from './types';
 
 // Key format: db:{id}|cat:{name}|schema:{name}|table:{name}
@@ -337,6 +338,7 @@ export function generatePermissionsPayload(
   permissionStates: Record<string, PermissionState>,
   databases: Map<number, string>,
   clsRules: Record<string, CLSAction> = {},
+  rlsRules: Record<string, RLSRule> = {},
 ): PermissionsPayload {
   const allowed: PermissionEntry[] = [];
   const denied: PermissionEntry[] = [];
@@ -369,6 +371,19 @@ export function generatePermissionsPayload(
     if (parsed.schemaName) entry.schema = parsed.schemaName;
     if (parsed.tableName) entry.table = parsed.tableName;
 
+    // Add RLS rules if this is a table entry and has RLS rules
+    if (parsed.tableName && rlsRules[key]) {
+      const rls = rlsRules[key];
+      if (rls.predicate) {
+        entry.rls = {
+          predicate: rls.predicate,
+        };
+        if (rls.groupKey) {
+          entry.rls.group_key = rls.groupKey;
+        }
+      }
+    }
+
     // Add CLS rules if this is a table entry and has CLS rules
     if (parsed.tableName && clsByTable[key]) {
       entry.cls = clsByTable[key];
@@ -381,9 +396,14 @@ export function generatePermissionsPayload(
     }
   });
 
-  // Also add CLS rules for tables that don't have explicit permission states
-  // but do have CLS rules (they inherit permission from parent)
-  Object.entries(clsByTable).forEach(([tableKey, columnRules]) => {
+  // Also add RLS/CLS rules for tables that don't have explicit permission states
+  // but do have RLS or CLS rules (they inherit permission from parent)
+  const tablesWithRules = new Set([
+    ...Object.keys(clsByTable),
+    ...Object.keys(rlsRules),
+  ]);
+
+  tablesWithRules.forEach(tableKey => {
     // Check if we already added this table
     const parsed = parseKey(tableKey);
     const databaseName = databases.get(parsed.databaseId);
@@ -398,17 +418,34 @@ export function generatePermissionsPayload(
         entry.table === parsed.tableName,
     );
 
-    if (!alreadyInAllowed && Object.keys(columnRules).length > 0) {
+    const hasClsRules =
+      clsByTable[tableKey] && Object.keys(clsByTable[tableKey]).length > 0;
+    const hasRlsRules =
+      rlsRules[tableKey] && rlsRules[tableKey].predicate;
+
+    if (!alreadyInAllowed && (hasClsRules || hasRlsRules)) {
       // Check if the table has effective allow state (inherited)
       const effectiveState = getEffectiveState(tableKey, permissionStates);
       if (effectiveState === 'allow') {
         const entry: PermissionEntry = {
           database: databaseName,
           table: parsed.tableName,
-          cls: columnRules,
         };
         if (parsed.catalogName) entry.catalog = parsed.catalogName;
         if (parsed.schemaName) entry.schema = parsed.schemaName;
+
+        if (hasRlsRules) {
+          const rls = rlsRules[tableKey];
+          entry.rls = { predicate: rls.predicate };
+          if (rls.groupKey) {
+            entry.rls.group_key = rls.groupKey;
+          }
+        }
+
+        if (hasClsRules) {
+          entry.cls = clsByTable[tableKey];
+        }
+
         allowed.push(entry);
       }
     }
@@ -457,9 +494,14 @@ function cleanupStates(
 export function loadPermissionsFromPayload(
   payload: PermissionsPayload,
   databases: Map<string, number>,
-): { states: Record<string, PermissionState>; clsRules: Record<string, CLSAction> } {
+): {
+  states: Record<string, PermissionState>;
+  clsRules: Record<string, CLSAction>;
+  rlsRules: Record<string, RLSRule>;
+} {
   const states: Record<string, PermissionState> = {};
   const clsRules: Record<string, CLSAction> = {};
+  const rlsRules: Record<string, RLSRule> = {};
 
   payload.allowed.forEach(entry => {
     const databaseId = databases.get(entry.database);
@@ -473,6 +515,14 @@ export function loadPermissionsFromPayload(
     });
     states[key] = 'allow';
 
+    // Load RLS rules if present
+    if (entry.rls && entry.table) {
+      rlsRules[key] = {
+        predicate: entry.rls.predicate,
+        groupKey: entry.rls.group_key,
+      };
+    }
+
     // Load CLS rules if present
     if (entry.cls && entry.table) {
       Object.entries(entry.cls).forEach(([columnName, action]) => {
@@ -495,5 +545,5 @@ export function loadPermissionsFromPayload(
     states[key] = 'deny';
   });
 
-  return { states, clsRules };
+  return { states, clsRules, rlsRules };
 }


(superset) 02/02: Add name and description

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

beto pushed a commit to branch new-dar
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 3ad694e5a96bd7e2e8370ca2d8e62dab00c6ce7e
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Wed Dec 17 21:52:32 2025 -0500

    Add name and description
---
 .../dataAccessRules/DataAccessRuleModal.tsx        | 68 +++++++++++++---------
 .../dataAccessRules/PermissionsTree/index.tsx      | 18 ++++--
 .../src/features/dataAccessRules/types.ts          |  2 +
 .../src/pages/DataAccessRulesList/index.tsx        | 48 +++++++++------
 superset/data_access_rules/api.py                  |  9 +++
 superset/data_access_rules/models.py               |  6 +-
 superset/data_access_rules/schemas.py              | 24 ++++++++
 ...90_add_name_description_to_data_access_rules.py | 43 ++++++++++++++
 8 files changed, 165 insertions(+), 53 deletions(-)

diff --git a/superset-frontend/src/features/dataAccessRules/DataAccessRuleModal.tsx b/superset-frontend/src/features/dataAccessRules/DataAccessRuleModal.tsx
index ee87e011cf..97f23db312 100644
--- a/superset-frontend/src/features/dataAccessRules/DataAccessRuleModal.tsx
+++ b/superset-frontend/src/features/dataAccessRules/DataAccessRuleModal.tsx
@@ -122,6 +122,8 @@ export interface DataAccessRuleModalProps {
 }
 
 const DEFAULT_RULE: DataAccessRuleObject = {
+  name: '',
+  description: '',
   role_id: 0,
   rule: JSON.stringify(
     {
@@ -133,19 +135,6 @@ const DEFAULT_RULE: DataAccessRuleObject = {
   ),
 };
 
-const RULE_EXAMPLE = `{
-  "allowed": [
-    {"database": "sales", "schema": "orders"},
-    {"database": "sales", "schema": "orders", "table": "prices",
-     "rls": {"predicate": "org_id = 123", "group_key": "org"}},
-    {"database": "sales", "schema": "users", "table": "info",
-     "cls": {"email": "mask", "ssn": "hide"}}
-  ],
-  "denied": [
-    {"database": "sales", "schema": "internal"}
-  ]
-}`;
-
 type SelectValue = {
   value: number;
   label: string;
@@ -318,6 +307,8 @@ function DataAccessRuleModal(props: DataAccessRuleModalProps) {
 
   const onSave = () => {
     const data = {
+      name: currentRule.name || null,
+      description: currentRule.description || null,
       role_id: selectedRole?.value,
       rule: currentRule.rule,
     };
@@ -403,6 +394,43 @@ function DataAccessRuleModal(props: DataAccessRuleModalProps) {
             </div>
           </StyledInputContainer>
 
+          <StyledInputContainer>
+            <div className="control-label">
+              {t('Name')}
+              <InfoTooltip
+                tooltip={t('Optional name to help identify this rule.')}
+              />
+            </div>
+            <div className="input-container">
+              <Input
+                name="name"
+                value={currentRule.name || ''}
+                onChange={e => updateRuleState('name', e.target.value)}
+                placeholder={t('e.g., Sales team access')}
+                data-test="rule-name"
+              />
+            </div>
+          </StyledInputContainer>
+
+          <StyledInputContainer>
+            <div className="control-label">
+              {t('Description')}
+              <InfoTooltip
+                tooltip={t('Optional description of what this rule grants or restricts.')}
+              />
+            </div>
+            <div className="input-container">
+              <Input.TextArea
+                name="description"
+                value={currentRule.description || ''}
+                onChange={e => updateRuleState('description', e.target.value)}
+                placeholder={t('Describe the purpose of this rule...')}
+                rows={2}
+                data-test="rule-description"
+              />
+            </div>
+          </StyledInputContainer>
+
           <StyledInputContainer>
             <div className="control-label">
               {t('Table Permissions')}
@@ -454,20 +482,6 @@ function DataAccessRuleModal(props: DataAccessRuleModalProps) {
                       )}
                     </StyledInputContainer>
 
-                    <StyledInputContainer>
-                      <div className="control-label">{t('Example')}</div>
-                      <pre
-                        style={{
-                          background: '#f5f5f5',
-                          padding: '12px',
-                          borderRadius: '4px',
-                          fontSize: '12px',
-                          overflow: 'auto',
-                        }}
-                      >
-                        {RULE_EXAMPLE}
-                      </pre>
-                    </StyledInputContainer>
                   </>
                 ),
               },
diff --git a/superset-frontend/src/features/dataAccessRules/PermissionsTree/index.tsx b/superset-frontend/src/features/dataAccessRules/PermissionsTree/index.tsx
index 4853977da9..e3bdf4e2a9 100644
--- a/superset-frontend/src/features/dataAccessRules/PermissionsTree/index.tsx
+++ b/superset-frontend/src/features/dataAccessRules/PermissionsTree/index.tsx
@@ -164,6 +164,16 @@ const StyledContainer = styled.div`
       max-width: 250px;
       font-size: 12px;
     }
+
+    .count-allowed {
+      color: ${theme.colorSuccess};
+      font-weight: ${theme.fontWeightSemiBold};
+    }
+
+    .count-denied {
+      color: ${theme.colorError};
+      font-weight: ${theme.fontWeightSemiBold};
+    }
   `}
 `;
 
@@ -684,13 +694,9 @@ function PermissionsTree({
         {hasCustomRules && (
           <span className="node-count">
             (
-            <span style={{ color: '#52c41a', fontWeight: 'bold' }}>
-              {counts.allowed}
-            </span>
+            <span className="count-allowed">{counts.allowed}</span>
             {' / '}
-            <span style={{ color: '#f5222d', fontWeight: 'bold' }}>
-              {counts.denied}
-            </span>
+            <span className="count-denied">{counts.denied}</span>
             )
           </span>
         )}
diff --git a/superset-frontend/src/features/dataAccessRules/types.ts b/superset-frontend/src/features/dataAccessRules/types.ts
index 1c4e804442..9b4cfa194d 100644
--- a/superset-frontend/src/features/dataAccessRules/types.ts
+++ b/superset-frontend/src/features/dataAccessRules/types.ts
@@ -24,6 +24,8 @@ export type RoleObject = {
 
 export type DataAccessRuleObject = {
   id?: number;
+  name?: string;
+  description?: string;
   role_id: number;
   role?: RoleObject;
   rule: string;
diff --git a/superset-frontend/src/pages/DataAccessRulesList/index.tsx b/superset-frontend/src/pages/DataAccessRulesList/index.tsx
index e2f29e0a50..721a1443e9 100644
--- a/superset-frontend/src/pages/DataAccessRulesList/index.tsx
+++ b/superset-frontend/src/pages/DataAccessRulesList/index.tsx
@@ -129,41 +129,53 @@ function DataAccessRulesList(props: DataAccessRulesListProps) {
       {
         Cell: ({
           row: {
-            original: { role },
+            original: { name },
           },
         }: {
           row: { original: DataAccessRuleObject };
-        }) => role?.name || '-',
-        accessor: 'role',
-        Header: t('Role'),
+        }) => name || '-',
+        accessor: 'name',
+        Header: t('Name'),
         size: 'lg',
-        id: 'role',
-        disableSortBy: true,
+        id: 'name',
       },
       {
         Cell: ({
           row: {
-            original: { rule },
+            original: { description },
           },
         }: {
           row: { original: DataAccessRuleObject };
         }) => {
-          const displayRule =
-            typeof rule === 'string' ? rule : JSON.stringify(rule);
+          if (!description) return '-';
           const truncated =
-            displayRule.length > 100
-              ? `${displayRule.substring(0, 100)}...`
-              : displayRule;
+            description.length > 100
+              ? `${description.substring(0, 100)}...`
+              : description;
           return (
-            <Tooltip id="rule-tooltip" title={displayRule} placement="top">
-              <code style={{ fontSize: '11px' }}>{truncated}</code>
+            <Tooltip id="desc-tooltip" title={description} placement="top">
+              <span>{truncated}</span>
             </Tooltip>
           );
         },
-        accessor: 'rule',
-        Header: t('Rule (JSON)'),
-        size: 'xxl',
-        id: 'rule',
+        accessor: 'description',
+        Header: t('Description'),
+        size: 'xl',
+        id: 'description',
+        disableSortBy: true,
+      },
+      {
+        Cell: ({
+          row: {
+            original: { role },
+          },
+        }: {
+          row: { original: DataAccessRuleObject };
+        }) => role?.name || '-',
+        accessor: 'role',
+        Header: t('Role'),
+        size: 'lg',
+        id: 'role',
         disableSortBy: true,
       },
       {
diff --git a/superset/data_access_rules/api.py b/superset/data_access_rules/api.py
index fcd54474fb..639b900377 100644
--- a/superset/data_access_rules/api.py
+++ b/superset/data_access_rules/api.py
@@ -63,6 +63,8 @@ class DataAccessRulesRestApi(BaseSupersetModelRestApi):
 
     list_columns = [
         "id",
+        "name",
+        "description",
         "role_id",
         "role.id",
         "role.name",
@@ -74,19 +76,26 @@ class DataAccessRulesRestApi(BaseSupersetModelRestApi):
     ]
     order_columns = [
         "id",
+        "name",
         "role_id",
         "changed_on_delta_humanized",
     ]
     add_columns = [
+        "name",
+        "description",
         "role_id",
         "rule",
     ]
     edit_columns = [
+        "name",
+        "description",
         "role_id",
         "rule",
     ]
     show_columns = [
         "id",
+        "name",
+        "description",
         "role_id",
         "role.name",
         "role.id",
diff --git a/superset/data_access_rules/models.py b/superset/data_access_rules/models.py
index 1aa166f7c2..f87e03da96 100644
--- a/superset/data_access_rules/models.py
+++ b/superset/data_access_rules/models.py
@@ -68,7 +68,7 @@ from __future__ import annotations
 from typing import Any
 
 from flask_appbuilder import Model
-from sqlalchemy import Column, ForeignKey, Integer, Text
+from sqlalchemy import Column, ForeignKey, Integer, String, Text
 from sqlalchemy.orm import relationship
 
 from superset import security_manager
@@ -87,6 +87,8 @@ class DataAccessRule(Model, AuditMixinNullable):
     __tablename__ = "data_access_rules"
 
     id = Column(Integer, primary_key=True)
+    name = Column(String(250), nullable=True)
+    description = Column(Text, nullable=True)
     role_id = Column(Integer, ForeignKey("ab_role.id"), nullable=False)
     rule = Column(Text, nullable=False)
 
@@ -97,7 +99,7 @@ class DataAccessRule(Model, AuditMixinNullable):
     )
 
     def __repr__(self) -> str:
-        return f"<DataAccessRule(id={self.id}, role_id={self.role_id})>"
+        return f"<DataAccessRule(id={self.id}, name={self.name!r}, role_id={self.role_id})>"
 
     @property
     def rule_dict(self) -> dict[str, Any]:
diff --git a/superset/data_access_rules/schemas.py b/superset/data_access_rules/schemas.py
index a1f7f1137a..cc344d5019 100644
--- a/superset/data_access_rules/schemas.py
+++ b/superset/data_access_rules/schemas.py
@@ -66,6 +66,8 @@ class DataAccessRuleListSchema(Schema):
     """Schema for listing data access rules."""
 
     id = fields.Integer(metadata={"description": "Unique ID of the rule"})
+    name = fields.String(metadata={"description": "Name of the rule"})
+    description = fields.String(metadata={"description": "Description of the rule"})
     role_id = fields.Integer(metadata={"description": "ID of the associated role"})
     role = fields.Nested(RoleSchema)
     rule = fields.String(metadata={"description": rule_description})
@@ -80,6 +82,8 @@ class DataAccessRuleShowSchema(Schema):
     """Schema for showing a single data access rule."""
 
     id = fields.Integer(metadata={"description": "Unique ID of the rule"})
+    name = fields.String(metadata={"description": "Name of the rule"})
+    description = fields.String(metadata={"description": "Description of the rule"})
     role_id = fields.Integer(metadata={"description": "ID of the associated role"})
     role = fields.Nested(RoleSchema)
     rule = fields.String(metadata={"description": rule_description})
@@ -92,6 +96,16 @@ class DataAccessRuleShowSchema(Schema):
 class DataAccessRulePostSchema(Schema):
     """Schema for creating a data access rule."""
 
+    name = fields.String(
+        metadata={"description": "Name for this rule (optional)"},
+        required=False,
+        allow_none=True,
+    )
+    description = fields.String(
+        metadata={"description": "Description of the rule (optional)"},
+        required=False,
+        allow_none=True,
+    )
     role_id = fields.Integer(
         metadata={"description": "ID of the role this rule applies to"},
         required=True,
@@ -159,6 +173,16 @@ class DataAccessRulePostSchema(Schema):
 class DataAccessRulePutSchema(Schema):
     """Schema for updating a data access rule."""
 
+    name = fields.String(
+        metadata={"description": "Name for this rule (optional)"},
+        required=False,
+        allow_none=True,
+    )
+    description = fields.String(
+        metadata={"description": "Description of the rule (optional)"},
+        required=False,
+        allow_none=True,
+    )
     role_id = fields.Integer(
         metadata={"description": "ID of the role this rule applies to"},
         required=False,
diff --git a/superset/migrations/versions/2025-12-17_12-00_b463d8709290_add_name_description_to_data_access_rules.py b/superset/migrations/versions/2025-12-17_12-00_b463d8709290_add_name_description_to_data_access_rules.py
new file mode 100644
index 0000000000..1068e9bbcb
--- /dev/null
+++ b/superset/migrations/versions/2025-12-17_12-00_b463d8709290_add_name_description_to_data_access_rules.py
@@ -0,0 +1,43 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""add name and description to data_access_rules
+
+Revision ID: b463d8709290
+Revises: a352d7609189
+Create Date: 2025-12-17 12:00:00.000000
+
+"""
+
+import sqlalchemy as sa
+
+from superset.migrations.shared.utils import add_columns, drop_columns
+
+# revision identifiers, used by Alembic.
+revision = "b463d8709290"
+down_revision = "a352d7609189"
+
+
+def upgrade():
+    add_columns(
+        "data_access_rules",
+        sa.Column("name", sa.String(250), nullable=True),
+        sa.Column("description", sa.Text(), nullable=True),
+    )
+
+
+def downgrade():
+    drop_columns("data_access_rules", "name", "description")