mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
Fixing druid culster perms to mirror sqla databases (#1123)
This commit is contained in:
parent
2adc8a0274
commit
edcc2a11c6
@ -1180,6 +1180,9 @@ class DruidCluster(Model, AuditMixinNullable):
|
|||||||
for datasource in self.get_datasources():
|
for datasource in self.get_datasources():
|
||||||
if datasource not in config.get('DRUID_DATA_SOURCE_BLACKLIST'):
|
if datasource not in config.get('DRUID_DATA_SOURCE_BLACKLIST'):
|
||||||
DruidDatasource.sync_to_db(datasource, self)
|
DruidDatasource.sync_to_db(datasource, self)
|
||||||
|
@property
|
||||||
|
def perm(self):
|
||||||
|
return "[{obj.cluster_name}].(id:{obj.id})".format(obj=self)
|
||||||
|
|
||||||
|
|
||||||
class DruidDatasource(Model, AuditMixinNullable, Queryable):
|
class DruidDatasource(Model, AuditMixinNullable, Queryable):
|
||||||
|
@ -628,6 +628,11 @@ class DruidClusterModelView(CaravelModelView, DeleteMixin): # noqa
|
|||||||
'broker_port': _("Broker Port"),
|
'broker_port': _("Broker Port"),
|
||||||
'broker_endpoint': _("Broker Endpoint"),
|
'broker_endpoint': _("Broker Endpoint"),
|
||||||
}
|
}
|
||||||
|
def pre_add(self, db):
|
||||||
|
utils.merge_perm(sm, 'database_access', db.perm)
|
||||||
|
|
||||||
|
def pre_update(self, db):
|
||||||
|
self.pre_add(db)
|
||||||
|
|
||||||
|
|
||||||
if config['DRUID_IS_ACTIVE']:
|
if config['DRUID_IS_ACTIVE']:
|
||||||
@ -1613,7 +1618,7 @@ class Caravel(BaseCaravelView):
|
|||||||
|
|
||||||
if not self.database_access(query.database):
|
if not self.database_access(query.database):
|
||||||
flash(get_database_access_error_msg(query.database.database_name))
|
flash(get_database_access_error_msg(query.database.database_name))
|
||||||
redirect('/')
|
return redirect('/')
|
||||||
|
|
||||||
sql = query.select_sql or query.sql
|
sql = query.select_sql or query.sql
|
||||||
df = query.database.get_df(sql, query.schema)
|
df = query.database.get_df(sql, query.schema)
|
||||||
|
Loading…
Reference in New Issue
Block a user