Vitor-Avila commented on code in PR #44992:
URL: https://github.com/apache/superset/pull/44992#discussion_r4202650600
##########
superset/reports/schemas.py:
##########
@@ -125,6 +127,46 @@
"Creation method is used to inform the frontend whether the report/alert
was "
"created in the dashboard, chart, or alerts and reports UI."
)
+run_as_description = (
+ "ID of the user whose credentials (RBAC permissions, database OAuth2
tokens) "
+ "are used when rendering the content (screenshot, PDF, CSV, XLSX or text).
"
+ "Admins can set any active user; non-admins can only set themselves. Only"
+ "honored when the ALERT_REPORT_DYNAMIC_EXECUTOR feature flag is enabled. "
+ "Admins can set this and run_as_type to null to use
ALERT_REPORTS_EXECUTORS."
+)
+run_alert_query_as_description = (
+ "ID of the user whose credentials are used when running the alert
condition "
+ "SQL query, useful when the audience of the alert does not have access to
the "
+ "database. Null inherits the content executor at execution time."
+)
+
+
+_RUN_AS_FIELD_KEYS = (
+ "run_as",
+ "run_alert_query_as",
+ "run_as_type",
+ "run_alert_query_as_type",
+)
+_REPORT_EXECUTOR_TYPES = [
+ ExecutorType.FIXED_USER,
+]
+
+
+class RunAsFieldStripMixin:
+ """Drop the "Run As" fields from the raw payload when the dynamic executor
+ feature (``ALERT_REPORT_DYNAMIC_EXECUTOR``) is disabled, so callers on the
+ legacy path never store an executor by accident."""
+
+ @pre_load
+ def strip_run_as_fields_if_disabled(
+ self,
+ data: dict[str, Any],
+ **kwargs: Any,
+ ) -> dict[str, Any]:
+ if not is_feature_enabled("ALERT_REPORT_DYNAMIC_EXECUTOR"):
Review Comment:
Sure thing! Test coverage added.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]