Fixing druid culster perms to mirror sqla databases (#1123)

This commit is contained in:
Maxime Beauchemin 2016-09-16 08:32:37 -07:00 committed by GitHub
parent 2adc8a0274
commit edcc2a11c6
2 changed files with 9 additions and 1 deletions

View File

@ -1180,6 +1180,9 @@ class DruidCluster(Model, AuditMixinNullable):
for datasource in self.get_datasources():
if datasource not in config.get('DRUID_DATA_SOURCE_BLACKLIST'):
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):

View File

@ -628,6 +628,11 @@ class DruidClusterModelView(CaravelModelView, DeleteMixin): # noqa
'broker_port': _("Broker Port"),
'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']:
@ -1613,7 +1618,7 @@ class Caravel(BaseCaravelView):
if not self.database_access(query.database):
flash(get_database_access_error_msg(query.database.database_name))
redirect('/')
return redirect('/')
sql = query.select_sql or query.sql
df = query.database.get_df(sql, query.schema)