From 23b8c08832f6e6ac7a12ef268d9b1112c9d11650 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt Date: Fri, 20 Jan 2023 10:24:57 +0200 Subject: [PATCH] fall back to selenium user --- UPDATING.md | 2 +- docs/docs/installation/cache.mdx | 3 ++- superset/config.py | 9 +++++---- tests/integration_tests/thumbnails_tests.py | 14 ++++++++++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/UPDATING.md b/UPDATING.md index c2a94ff8c45bc..2ebe7fb111dd6 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -34,7 +34,7 @@ assists people when migrating to a new version. ### Breaking Changes -- [22801](https://github.com/apache/superset/pull/22801): The Thumbnails feature has been changed to execute as the currently logged in user by default. To continue using the selenium user, please add the following to your `superset_config.py`: `THUMBNAILS_EXECUTE_AS = ["selenium"]` +- [22801](https://github.com/apache/superset/pull/22801): The Thumbnails feature has been changed to execute as the currently logged in user by default, falling back to the selenium user for anonymous users. To continue always using the selenium user, please add the following to your `superset_config.py`: `THUMBNAILS_EXECUTE_AS = ["selenium"]` - [22328](https://github.com/apache/superset/pull/22328): For deployments that have enabled the "THUMBNAILS" feature flag, the function that calculates dashboard digests has been updated to consider additional properties to more accurately identify changes in the dashboard metadata. This change will invalidate all currently cached dashboard thumbnails. - [21765](https://github.com/apache/superset/pull/21765): For deployments that have enabled the "ALERT_REPORTS" feature flag, Gamma users will no longer have read and write access to Alerts & Reports by default. To give Gamma users the ability to schedule reports from the Dashboard and Explore view like before, create an additional role with "can read on ReportSchedule" and "can write on ReportSchedule" permissions. To further give Gamma users access to the "Alerts & Reports" menu and CRUD view, add "menu access on Manage" and "menu access on Alerts & Report" permissions to the role. - [22325](https://github.com/apache/superset/pull/22325): "RLS_FORM_QUERY_REL_FIELDS" is replaced by "RLS_BASE_RELATED_FIELD_FILTERS" feature flag.Its value format stays same. diff --git a/docs/docs/installation/cache.mdx b/docs/docs/installation/cache.mdx index 15450bae046ad..5b2d908961dcd 100644 --- a/docs/docs/installation/cache.mdx +++ b/docs/docs/installation/cache.mdx @@ -87,7 +87,8 @@ FEATURE_FLAGS = { } ``` -By default thumbnails are rendered per user. To render thumbnails as a fixed user (`admin` in this example), use the following configuration: +By default thumbnails are rendered per user, and will fall back to the Selenium user for anonymous users. +To always render thumbnails as a fixed user (`admin` in this example), use the following configuration: ```python from superset.tasks.types import ExecutorType diff --git a/superset/config.py b/superset/config.py index 4e5ebf2791c98..c501446fcb906 100644 --- a/superset/config.py +++ b/superset/config.py @@ -611,13 +611,14 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]: # --------------------------------------------------- # Thumbnail config (behind feature flag) # --------------------------------------------------- -# By default, thumbnails are rendered per user. Similar to Alerts & Reports, thumbnails -# can be configured to be rendered as a fixed user. See +# By default, thumbnails are rendered per user, and will fall back to the Selenium +# user for anonymous users. Similar to Alerts & Reports, thumbnails +# can be configured to always be rendered as a fixed user. See # `superset.tasks.types.ExecutorType` for a full list of executor options. -# To use a fixed user account, use the following configuration: +# To always use a fixed user account, use the following configuration: # THUMBNAIL_EXECUTE_AS = [ExecutorType.SELENIUM] THUMBNAIL_SELENIUM_USER: Optional[str] = "admin" -THUMBNAIL_EXECUTE_AS = [ExecutorType.CURRENT_USER] +THUMBNAIL_EXECUTE_AS = [ExecutorType.CURRENT_USER, ExecutorType.SELENIUM] # By default, thumbnail digests are calculated based on various parameters in the # chart/dashboard metadata, and in the case of user-specific thumbnails, the diff --git a/tests/integration_tests/thumbnails_tests.py b/tests/integration_tests/thumbnails_tests.py index efa0d73cb49f0..5cb45a7637a5c 100644 --- a/tests/integration_tests/thumbnails_tests.py +++ b/tests/integration_tests/thumbnails_tests.py @@ -239,7 +239,12 @@ def test_get_async_dashboard_screenshot_as_selenium(self): Thumbnails: Simple get async dashboard screenshot as selenium user """ self.login(username="alpha") - with patch( + with patch.dict( + "superset.thumbnails.digest.current_app.config", + { + "THUMBNAIL_EXECUTE_AS": [ExecutorType.SELENIUM], + }, + ), patch( "superset.thumbnails.digest._adjust_string_for_executor" ) as mock_adjust_string: mock_adjust_string.return_value = self.digest_return_value @@ -306,7 +311,12 @@ def test_get_async_chart_screenshot_as_selenium(self): Thumbnails: Simple get async chart screenshot as selenium user """ self.login(username="alpha") - with patch( + with patch.dict( + "superset.thumbnails.digest.current_app.config", + { + "THUMBNAIL_EXECUTE_AS": [ExecutorType.SELENIUM], + }, + ), patch( "superset.thumbnails.digest._adjust_string_for_executor" ) as mock_adjust_string: mock_adjust_string.return_value = self.digest_return_value