mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
feat(reports): execute as other than selenium user (#21931)
Co-authored-by: Ville Brofeldt <ville.brofeldt@apple.com>
This commit is contained in:
@@ -371,10 +371,36 @@ to specify on behalf of which username to render the dashboards. In general dash
|
||||
are not accessible to unauthorized requests, that is why the worker needs to take over credentials
|
||||
of an existing user to take a snapshot.
|
||||
|
||||
By default, Alerts and Reports are executed as the user that the `THUMBNAIL_SELENIUM_USER` config
|
||||
parameter is set to. To change this user, just change the config as follows:
|
||||
|
||||
```python
|
||||
THUMBNAIL_SELENIUM_USER = 'username_with_permission_to_access_dashboards'
|
||||
```
|
||||
|
||||
In addition, it's also possible to execute the reports as the report owners/creators. This is typically
|
||||
needed if there isn't a central service account that has access to all objects or databases (e.g.
|
||||
when using user impersonation on database connections). For this there's the config flag
|
||||
`ALERTS_REPORTS_EXECUTE_AS` which makes it possible to customize how alerts and reports are executed.
|
||||
To first try to execute as the creator in the owners list (if present), then fall
|
||||
back to the creator, then the last modifier in the owners list (if present), then the
|
||||
last modifier, then an owner (giving priority to the last modifier and then the
|
||||
creator if either is contained within the list of owners, otherwise the first owner
|
||||
will be used) and finally `THUMBNAIL_SELENIUM_USER`, set as follows:
|
||||
|
||||
```python
|
||||
from superset.reports.types import ReportScheduleExecutor
|
||||
|
||||
ALERT_REPORTS_EXECUTE_AS = [
|
||||
ReportScheduleExecutor.CREATOR_OWNER,
|
||||
ReportScheduleExecutor.CREATOR,
|
||||
ReportScheduleExecutor.MODIFIER_OWNER,
|
||||
ReportScheduleExecutor.MODIFIER,
|
||||
ReportScheduleExecutor.OWNER,
|
||||
ReportScheduleExecutor.SELENIUM,
|
||||
]
|
||||
```
|
||||
|
||||
**Important notes**
|
||||
|
||||
- Be mindful of the concurrency setting for celery (using `-c 4`). Selenium/webdriver instances can
|
||||
@@ -382,7 +408,7 @@ THUMBNAIL_SELENIUM_USER = 'username_with_permission_to_access_dashboards'
|
||||
- In some cases, if you notice a lot of leaked geckodriver processes, try running your celery
|
||||
processes with `celery worker --pool=prefork --max-tasks-per-child=128 ...`
|
||||
- It is recommended to run separate workers for the `sql_lab` and `email_reports` tasks. This can be
|
||||
done using the `queue` field in `CELERY_ANNOTATIONS`.
|
||||
done using the `queue` field in `task_annotations`.
|
||||
- Adjust `WEBDRIVER_BASEURL` in your configuration file if celery workers can’t access Superset via
|
||||
its default value of `http://0.0.0.0:8080/`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user