feat(row-level-security): add hook for customizing form dropdowns (#10683)

This commit is contained in:
Ville Brofeldt 2020-08-26 11:55:35 +03:00 committed by GitHub
parent a6101f72c9
commit 4251b4e294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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