You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2020/08/26 08:56:07 UTC

[incubator-superset] branch master updated: feat(row-level-security): add hook for customizing form dropdowns (#10683)

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

villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 4251b4e  feat(row-level-security): add hook for customizing form dropdowns (#10683)
4251b4e is described below

commit 4251b4e29405b21fad32ddc70807a04696c69374
Author: Ville Brofeldt <33...@users.noreply.github.com>
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 db5aa6e..0dfde99 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -869,6 +869,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 107e10a..23f4c1c 100644
--- a/superset/connectors/sqla/views.py
+++ b/superset/connectors/sqla/views.py
@@ -274,6 +274,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