Skip to content

Commit

Permalink
feat(row-level-security): add hook for customizing form dropdowns (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro authored Aug 26, 2020
1 parent a6101f7 commit 4251b4e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,16 @@ class CeleryConfig: # pylint: disable=too-few-public-methods
# 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
Expand Down
3 changes: 3 additions & 0 deletions superset/connectors/sqla/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4251b4e

Please sign in to comment.