GitHub user FrancescoCastaldi added a comment to the discussion: rls rule

In Superset, the guest token Row Level Security payload does not use a 
`"tables"` array. Instead, the backend security manager matches RLS rules 
against the specific dataset using the `"dataset"` key.

You can inspect the exact matching logic in `superset/security/manager.py` 
inside `get_guest_rls_filters`:

```python
# From superset/security/manager.py
if guest_user := self.get_current_guest_user_if_guest():
    return [
        rule
        for rule in guest_user.rls
        if not rule.get("dataset")
        or str(rule.get("dataset")) == str(dataset.data["id"])
    ]
```

### How to Target a Specific Dataset in the Guest Token

To apply an RLS rule exclusively to one datasource in an embedded dashboard 
with multiple charts, provide the numeric `dataset` ID:

```json
{
  "user": {
    "username": "guest_user",
    "first_name": "Guest",
    "last_name": "User"
  },
  "resources": [
    {
      "type": "dashboard",
      "id": "YOUR_DASHBOARD_UUID"
    }
  ],
  "rls": [
    {
      "clause": "RPM_FOR_NAME = 'COMPANY_NAME'",
      "dataset": 42
    }
  ]
}
```

### Key Rules:
1. Replace `42` with the actual integer ID of your dataset (you can find the ID 
in Superset under **Data -> Datasets**, listed in the ID column or in the URL 
`/explore/?dataset_id=42`).
2. If you omit the `"dataset"` property from an RLS rule, Superset applies the 
clause globally to **all** datasets in the dashboard.
3. If your dashboard has multiple datasources that each need different filters, 
include multiple rule objects in the `"rls"` array, each with its corresponding 
`"dataset"` ID.


GitHub link: 
https://github.com/apache/superset/discussions/41558#discussioncomment-19164788

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to