Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(chart): Enable caching per user when user impersonation is enabled #20114

Merged
merged 14 commits into from
Jun 21, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
get_virtual_table_metadata,
validate_adhoc_subquery,
)
from superset.databases.utils import make_url_safe
from superset.datasets.models import Dataset as NewDataset
from superset.db_engine_specs.base import BaseEngineSpec, CTE_ALIAS, TimestampExpression
from superset.exceptions import (
Expand Down Expand Up @@ -2026,6 +2027,15 @@ class and any keys added via `ExtraCache`.
if self.has_extra_cache_key_calls(query_obj):
sqla_query = self.get_sqla_query(**query_obj)
extra_cache_keys += sqla_query.extra_cache_keys

sqlalchemy_url = make_url_safe(self.database.sqlalchemy_uri_decrypted)

if effective_user := self.database.get_effective_user(sqlalchemy_url):
logger.debug("User impersonation is enabled for database '%s', adding "
"current username to '%s' datasource's extra cache keys",
self.database_name, self.datasource_name)
extra_cache_keys.append(effective_user)
Samira-El marked this conversation as resolved.
Show resolved Hide resolved

return extra_cache_keys

@property
Expand Down