GitHub user dosubot[bot] added a comment to the discussion: To add custom role 
via superset_config.py

<!-- Answer -->
There isn't a supported way to declaratively create or configure custom roles 
(with specific permissions) directly in superset_config.py. This file is 
intended for configuration, not for programmatic role or permission management. 
You can use superset_config.py to set role-related options like 
`PUBLIC_ROLE_LIKE` or `GUEST_ROLE_NAME` (which control how permissions are 
copied to the Public role or which role is used for guest/embedded users), but 
you still need to create and configure the actual roles and permissions via the 
UI, API, or CLI 
([discussion](https://github.com/apache/superset/discussions/33674)).

If you need to automate role creation, the recommended approach is to use the 
Superset UI (Security → List Roles), the Flask AppBuilder security API (enable 
with `FAB_ADD_SECURITY_API = True` in superset_config.py), or by customizing 
the `SupersetSecurityManager` class ([code 
reference](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/security/manager.py)).
 While you technically can run arbitrary Python code in superset_config.py, 
there is no officially supported or documented hook to safely create or modify 
roles at startup via this file.

For restricting a role to only see dashboards and charts, create the role via 
the UI or API, assign only the necessary permissions (like `can_read` on 
dashboards and charts), and assign users to that role. If you want to automate 
this, consider writing a custom initialization script or using the security 
API, not superset_config.py 
([reference](https://github.com/apache/superset/issues/31637)).


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/d1b5a066-ff27-403a-8c30-31b31cd808ef?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/d1b5a066-ff27-403a-8c30-31b31cd808ef?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/d1b5a066-ff27-403a-8c30-31b31cd808ef?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/d1b5a066-ff27-403a-8c30-31b31cd808ef?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/d1b5a066-ff27-403a-8c30-31b31cd808ef?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/d1b5a066-ff27-403a-8c30-31b31cd808ef?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/d1b5a066-ff27-403a-8c30-31b31cd808ef?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat
 with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
 nbsp;[![Join 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/34551)

GitHub link: 
https://github.com/apache/superset/discussions/34551#discussioncomment-14004321

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: 
notifications-unsubscr...@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to