This is an automated email from the ASF dual-hosted git repository. villebro pushed a commit to branch 0.37 in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 091c6ae3162e2c75d748c897bf308897a833c5d6 Author: Ville Brofeldt <[email protected]> AuthorDate: Wed Aug 26 11:55:35 2020 +0300 feat(row-level-security): add hook for customizing form dropdowns (#10683) --- superset/config.py | 10 ++++++++++ superset/connectors/sqla/views.py | 3 +++ 2 files changed, 13 insertions(+) diff --git a/superset/config.py b/superset/config.py index b8dc1d0..be7631a 100644 --- a/superset/config.py +++ b/superset/config.py @@ -846,6 +846,16 @@ TALISMAN_CONFIG = { # a custom security config could potentially give access to setting filters on # tables that users do not have access to. ENABLE_ROW_LEVEL_SECURITY = False +# It is possible to customize which tables and roles are featured in the RLS +# dropdown. When set, this dict is assigned to `add_form_query_rel_fields` and +# `edit_form_query_rel_fields` on `RowLevelSecurityFiltersModelView`. Example: +# +# from flask_appbuilder.models.sqla import filters +# RLS_FORM_QUERY_REL_FIELDS = { +# "roles": [["name", filters.FilterStartsWith, "RlsRole"]] +# "tables": [["table_name", filters.FilterContains, "rls"]] +# } +RLS_FORM_QUERY_REL_FIELDS: Optional[Dict[str, List[List[Any]]]] = None # # Flask session cookie options diff --git a/superset/connectors/sqla/views.py b/superset/connectors/sqla/views.py index 5f3466f..8cca0d6 100644 --- a/superset/connectors/sqla/views.py +++ b/superset/connectors/sqla/views.py @@ -263,6 +263,9 @@ class RowLevelSecurityFiltersModelView( # pylint: disable=too-many-ancestors "creator": _("Creator"), "modified": _("Modified"), } + if app.config["RLS_FORM_QUERY_REL_FIELDS"]: + add_form_query_rel_fields = app.config["RLS_FORM_QUERY_REL_FIELDS"] + edit_form_query_rel_fields = add_form_query_rel_fields class TableModelView( # pylint: disable=too-many-ancestors
