timifasubaa closed pull request #4704: allow customizable caching permissions
URL: https://github.com/apache/incubator-superset/pull/4704
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/superset/security.py b/superset/security.py
index 8ea91b9415..d239a60d2f 100644
--- a/superset/security.py
+++ b/superset/security.py
@@ -110,6 +110,10 @@ def schema_access(self, datasource, user=None):
self.can_access('schema_access', datasource.schema_perm, user=user)
)
+ def has_cache_access(self, datasource):
+ # By default if you can access the datasource, you can access the cache
+ return True
+
def datasource_access(self, datasource, user=None):
return (
self.schema_access(datasource, user=user) or
diff --git a/superset/viz.py b/superset/viz.py
index fc87430161..407179f3e7 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -34,7 +34,7 @@
from six import string_types, text_type
from six.moves import cPickle as pkl, reduce
-from superset import app, cache, get_manifest_file, utils
+from superset import app, cache, get_manifest_file, security_manager, utils
from superset.utils import DTTM_ALIAS, merge_extra_filters
@@ -309,7 +309,10 @@ def get_df_payload(self, query_obj=None):
stacktrace = None
df = None
cached_dttm = datetime.utcnow().isoformat().split('.')[0]
- if cache_key and cache and not self.force:
+ if (
+ cache_key and cache and not self.force and
+ security_manager.has_cache_access(self.datasource)
+ ):
cache_value = cache.get(cache_key)
if cache_value:
stats_logger.incr('loaded_from_cache')
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services